Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: error boundary in layout to handle application errors / crashes #1108

Merged

Conversation

catosaurusrex2003
Copy link
Contributor

Description
As proposed and discussed here #1101 (comment).

Changes proposed in this pull request:

  1. Added an error boundary in layout to handle errors generated by infinite recursion and such so that the application doesnt crash into an irrecoverable state.

  2. Reused the already existing Error component to render error,

Related issue(s)
#1100

@catosaurusrex2003
Copy link
Contributor Author

catosaurusrex2003 commented Nov 14, 2024

In Firefox:

image
image
image

In Chrome:

image

The Error Boundary is detecting the error being generated by the browser on too much recursion and rendering the Error component.

Used this asyncapi document for testing

asyncapi: 3.0.0
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  userSignedup:
    address: user/signedup
    messages:
      UserSignedUp:
        $ref: '#/components/messages/UserSignedUp'
    x-recursion:  #RECURSION here
      $ref: '#'
operations:
  sendUserSignedup:
    action: send
    channel:
      $ref: '#/channels/userSignedup'
    messages:
      - $ref: '#/channels/userSignedup/messages/UserSignedUp'
    x-recursion: #RECURSION here
      $ref: '#'
components:
  messages:
    UserSignedUp:
      x-recursion: #RECURSION here
        $ref: '#'
      payload:
        type: object
        properties:
          x-recursion: #RECURSION here
            $ref: '#'
          displayName:
            type: string
            description: Name of the user
          email:
            type: string

@catosaurusrex2003
Copy link
Contributor Author

@reachaadrika could you please review this pull request too when you get a chance? 😄 Thanks in advance!

Copy link
Member

@AceTheCreator AceTheCreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome improvement, but i noticed when i fix the recursive properties in the schema, the error still persists in the UI until i either refresh or re-paste a valid schema 🤔

library/src/containers/AsyncApi/Layout.tsx Outdated Show resolved Hide resolved
@catosaurusrex2003
Copy link
Contributor Author

but i noticed when i fix the recursive properties in the schema, the error still persists in the UI until i either refresh or re-paste a valid schema 🤔

Thanks for highlighting that. Have put some logic to rerender the component fresh.

Copy link

sonarqubecloud bot commented Dec 2, 2024

Copy link
Member

@AceTheCreator AceTheCreator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@AceTheCreator
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 47bc184 into asyncapi:master Dec 2, 2024
10 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 2.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants