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

[WEB] ReferenceError: setImmediate is not defined #712

Closed
devoren opened this issue Nov 30, 2024 · 5 comments · Fixed by #715
Closed

[WEB] ReferenceError: setImmediate is not defined #712

devoren opened this issue Nov 30, 2024 · 5 comments · Fixed by #715
Assignees
Labels
🎯 crash Library triggers a crash of the app repro provided Issue contains reproduction repository/code 🌐 web Web specific

Comments

@devoren
Copy link

devoren commented Nov 30, 2024

Describe the bug
I get an error when I use react-native-keyboard-controller on the web. When i open website: If I use it in another page and not in the page that is open, then I can use it when I go to the page where I use react-native-keyboard-controller. But if I reload the tab in those pages that I use react-native-keyboard-controller or the first page uses react-native-keyboard-controller, then it will not have time to initialize somehow and gives an error:
ReferenceError: setImmediate is not defined

I USED npx expo export -p web THEN npx serve dist --single (same in the prod)

Code snippet
In my case i use KeyboardAwareScrollView

<KeyboardAwareScrollView>
  {children}
</KeyboardAwareScrollView>

Repo for reproducing
https://github.com/devoren/rnkc-web-bug

To Reproduce
Steps to reproduce the behavior:

  1. Init new expo app
  2. Add RNKC
  3. Build expo web app (npx expo export -p web && npx serve dist --single)
  4. Reload the tab you are in on a page that uses the react-native-keyboard-controller component and See error

Expected behavior
Reload without any issues

Screenshots
If applicable, add screenshots to help explain your problem.
image

Smartphone (please complete the following information):

  • Desktop OS: [Windows 11]
  • Device: [Chrome]
  • OS: [Windows 11]
  • RN version: [0.76.2]
  • RN architecture: [any]
  • JS engine: [Hermes]
  • Library version: [^1.14.5]

Additional context
This only happens when I build the expo web app via npx expo export -p web and if I use it in development mode it works without any issues.

"web": {
	"bundler": "metro",
	"favicon": "./assets/images/favicon.png"
},

As I see, setImmediate is used once in the codebase:

setImmediate(attachWorkletHandlers);

I hope that these issues and pulls can help:
software-mansion/react-native-reanimated#4140
software-mansion/react-native-reanimated#4276

@kirillzyusko kirillzyusko added 🎯 crash Library triggers a crash of the app 🌐 web Web specific labels Nov 30, 2024
@kirillzyusko
Copy link
Owner

Thank you @devoren for issue and all the information ❤️

I'll try to see if I can use queueMicrotask to solve the original problem when I added setImmediate. Thank you again!

@kirillzyusko kirillzyusko added the repro provided Issue contains reproduction repository/code label Dec 2, 2024
@kirillzyusko
Copy link
Owner

@devoren may I ask you to test #715 to confirm it fixes the problem?

@devoren
Copy link
Author

devoren commented Dec 3, 2024

@kirillzyusko Hey! Ok thank you! I'll try

@devoren
Copy link
Author

devoren commented Dec 4, 2024

@kirillzyusko Hello! I think #715 fixed the problem!

@kirillzyusko
Copy link
Owner

@devoren awesome! Merged it and will publish under 1.15.0 this month 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🎯 crash Library triggers a crash of the app repro provided Issue contains reproduction repository/code 🌐 web Web specific
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants