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

Add better messaging on Vitest Pool Workers and nodejs_compat #18495

Merged
merged 5 commits into from
Jan 8, 2025

Conversation

andyjessop
Copy link
Contributor

Summary

Improves the messaging surrounding nodejs_compat and Vitest Pool Workers as a result of this PR which automatically injects nodejs_compat flag into the pool Worker.

Documentation checklist

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

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

1 files reviewed, 1 total issue(s) found.

Copy link

cloudflare-workers-and-pages bot commented Dec 2, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: cd39881
Status: ✅  Deploy successful!
Preview URL: https://3c325fb3.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://aj-vitest-pool-workers-node.cloudflare-docs-7ou.pages.dev

View logs


:::caution


Using the pool may cause your Worker to behave differently when deployed than during testing, as Node-style resolution and additional polyfills will be available to your Worker's source code and dependencies too.
Using Vitest Pool Workers may cause your Worker to behave differently when deployed than during testing as the `nodejs_compat` flag is enabled by default. This means that Node.js-specific APIs and modules are available when running your tests. However, Cloudflare Workers do not support these Node.js APIs in the production environment unless you specify this flag in your Worker configuration.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we explicitly link people at this point to add the flag

And maybe give basic example? Like — in your tests, you'll see that your Worker's code can use xyz node.js API. But when you deploy, unless flag is enabled, this wont' work, so your tests can give you false positive.

Think this is really close but showing vs. telling will really help to clarify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, I'll make that update. Thanks for the input @irvinebroque 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a more detailed explanation with code example.

@github-actions github-actions bot added size/m and removed size/xs labels Dec 17, 2024
@andyjessop andyjessop force-pushed the aj/vitest-pool-workers-node-compat branch from 0d8f7c5 to b681bb9 Compare December 17, 2024 09:28
@github-actions github-actions bot added size/xs and removed size/m labels Dec 17, 2024
@github-actions github-actions bot added size/s and removed size/xs labels Dec 19, 2024
@andyjessop andyjessop marked this pull request as ready for review December 19, 2024 08:11
@andyjessop andyjessop requested review from a team as code owners December 19, 2024 08:11
@andyjessop andyjessop merged commit d943fce into production Jan 8, 2025
12 checks passed
@andyjessop andyjessop deleted the aj/vitest-pool-workers-node-compat branch January 8, 2025 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:workers Related to Workers product size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants