Skip to content

Fix node timers #619

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

Merged
merged 6 commits into from
May 2, 2025
Merged

Fix node timers #619

merged 6 commits into from
May 2, 2025

Conversation

conico974
Copy link
Collaborator

It is expected that the global timers (i.e. setInterval, setTimeout) in Node returns a Nodejs.Timeout instead of a number. On cloudflare workers they return a number.

This can cause some unexpected crash like in #587, where sentry tries to call unref() on the created interval.
This PR fix #587

The only downsides to doing that is that in the middleware we'll have access to the Node version as well, but i don't think this is too big of an issue

Copy link

changeset-bot bot commented Apr 30, 2025

🦋 Changeset detected

Latest commit: 6b466c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Apr 30, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@619

commit: 6b466c9

@vicb
Copy link
Contributor

vicb commented Apr 30, 2025

Thanks for the fix @conico974

FYI this was discussed internally and we decided that mixing APIs would not be a problem (documented here).

I'll raise the issue again internally.

One possible fix would be to update unenv (with the caveat that external modules would not be polyfilled).

For now I'm +1 for this PR.

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks!

Added a link to workerd code

Co-authored-by: Victor Berchet <victor@suumit.com>
@conico974 conico974 merged commit 09aaf35 into opennextjs:main May 2, 2025
7 checks passed
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.

[BUG] Adding Sentry causes app to crash in preview mode
2 participants