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

Crash: TypeError: Cannot assign to read only property 'components' of object '#<Object>' #2174

Closed
euvs opened this issue Sep 21, 2022 · 0 comments · Fixed by #2179
Closed

Comments

@euvs
Copy link

euvs commented Sep 21, 2022

Describe the bug

I'm using RedocStandalone react component to render open api spec object.

<RedocStandalone  spec={graphqlServerResp.openAPI3Schema}  />

I'm getting this crash:

TypeError: Cannot assign to read only property 'components' of object '#<Object>'

I tracked down the place where the crash is happening. It's in @redocly/openapi-core package on this line:
https://github.com/Redocly/redocly-cli/blob/a3f955768baf6875911324582bc1f5c6c72b29ad/packages/core/src/bundle.ts#L260

The code tries to modify the passed object but fails. I believe it is caused by the fact that the spec object is being immutable.

To workaround the problem I make a copy of an object before passing it in to the component like so

<RedocStandalone  spec={{...graphqlServerResp.openAPI3Schema}}  />

and the crash is gone.

To Reproduce
Pass an immutable spec object.

Expected behavior
No crash

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

Successfully merging a pull request may close this issue.

2 participants