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

Expose all built-in options for getConstructor #1050

Merged

Conversation

hibachrach
Copy link
Contributor

@hibachrach hibachrach commented Jan 10, 2020

Summary

This enables us to easily override getConstructor to not use global
fallback, avoiding the all-consuming try...catch.

Other Information

Here's the context:

Quoting #264 (comment)

Regarding Encountered error "#<ExecJS::ProgramError: Invariant Violation: Element type is invalid: ...:

I think one of the core issues is that module lookup uses
try...catch
.
While the errors are logged to the console shim, that typically doesn't
help as a later error (such as the invariant violation) will lead to a
fatal error (triggering a 500). If that could be refactored to be a bit
more intentional based on environment (instead of just reacting based on
exceptions, or at the very least, throwing if the caught exception isn't
very specific)

@hibachrach hibachrach marked this pull request as ready for review January 10, 2020 21:04
@justin808
Copy link
Collaborator

@HarrisonB can you rebase this on master?

@hibachrach
Copy link
Contributor Author

Sure! I'll hopefully get to it in the next week or two

@hibachrach hibachrach force-pushed the add-additional-options-for-getConstructor branch from ee7a0f4 to 332667d Compare August 18, 2022 04:25
@hibachrach
Copy link
Contributor Author

@justin808 updated!

@justin808
Copy link
Collaborator

@HarrisonB can you confirm that all unit tests run locally?

Currently, we don't have CI working. We need to move to GH Actions.

@hibachrach
Copy link
Contributor Author

Having some trouble--See #1198 (comment)

@justin808
Copy link
Collaborator

@hibachrach is this ready for merge?

@hibachrach
Copy link
Contributor Author

yes, though we should have it trigger CI to make sure it passes. is there a way to do that on your end?

@justin808
Copy link
Collaborator

@hibachrach did you rebase on master where the github actions are defined?

Quoting reactjs#264 (comment)

> Regarding `Encountered error "#<ExecJS::ProgramError: Invariant
> Violation: Element type is invalid: ...`:
>
> I think one of the core issues is that [module lookup uses
> `try...catch`](https://github.com/reactjs/react-rails/blob/master/react_ujs/src/getConstructor/fromRequireContextWithGlobalFallback.js#L11-L23).
> While the errors are logged to the console shim, that typically doesn't
> help as a later error (such as the invariant violation) will lead to a
> fatal error (triggering a 500). If that could be refactored to be a bit
> more intentional based on environment (instead of just reacting based on
> exceptions, or at the very least, throwing if the caught exception isn't
> very specific)

This enables us to easily override `getConstructor` to not use global
fallback, avoiding the all-consuming `try...catch`.
@hibachrach hibachrach force-pushed the add-additional-options-for-getConstructor branch from 332667d to 9aabc79 Compare September 30, 2022 15:16
@hibachrach
Copy link
Contributor Author

Tests are now passing!

@alkesh26
Copy link
Collaborator

alkesh26 commented Oct 7, 2022

@justin808 The PR is good to go if we have no review comments.

@justin808 justin808 merged commit 4cbf13d into reactjs:master Oct 19, 2022
@justin808
Copy link
Collaborator

Thanks @hibachrach!

@hibachrach hibachrach deleted the add-additional-options-for-getConstructor branch October 19, 2022 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants