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

feat: recommend node compat on builtin use #1027

Merged
merged 7 commits into from
May 17, 2022

Conversation

rozenmd
Copy link
Contributor

@rozenmd rozenmd commented May 16, 2022

TODO:

  • Figure out if the example node app is in the right place
  • Write tests!

Closes #989

@changeset-bot
Copy link

changeset-bot bot commented May 16, 2022

🦋 Changeset detected

Latest commit: 5c4145f

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

This PR includes changesets to release 1 package
Name Type
wrangler 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

@github-actions
Copy link
Contributor

github-actions bot commented May 16, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2333487697/npm-package-wrangler-1027

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1027/npm-package-wrangler-1027

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2333487697/npm-package-wrangler-1027 dev path/to/script.js

Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

This needs a test! Write a test that tries to bundle a worker with a node built in, and make sure it throws the error you specified

packages/wrangler/src/bundle.ts Outdated Show resolved Hide resolved
packages/wrangler/src/bundle.ts Outdated Show resolved Hide resolved
packages/wrangler/src/bundle.ts Outdated Show resolved Hide resolved
@threepointone
Copy link
Contributor

threepointone commented May 16, 2022

The windows CI failure is because of #977, investigating that separately

@rozenmd rozenmd marked this pull request as ready for review May 16, 2022 14:43
@rozenmd rozenmd requested a review from petebacondarwin as a code owner May 16, 2022 14:43
Copy link
Contributor

@threepointone threepointone left a comment

Choose a reason for hiding this comment

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

Looks good to me! This should be a patch changeset btw. Approving for now, but please don't land until we fix the windows CI issue, thanks!

.changeset/tricky-actors-pretend.md Outdated Show resolved Hide resolved
),
},
() => {
throw new Error(
Copy link
Contributor

@JacobMGEvans JacobMGEvans May 16, 2022

Choose a reason for hiding this comment

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

Should use the logger Error utility

logger.error()

Copy link
Contributor

Choose a reason for hiding this comment

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

We went it to throw an error though, not just log

Copy link
Contributor

@JacobMGEvans JacobMGEvans May 16, 2022

Choose a reason for hiding this comment

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

throw the logger.error or we should add the ability to pass a option that has the logger throw Error seems like it should somehow be consistent and utilize the utility, I will unblock the PR regardless

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand, the logger only logs, but we want this to be an exception. We log the error to the terminal the error when it gets caught anyway. Where are we missing consistency?

Copy link
Contributor

@JacobMGEvans JacobMGEvans May 16, 2022

Choose a reason for hiding this comment

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

I don't understand, the logger only logs, but we want this to be an exception. We log the error to the terminal the error when it gets caught anyway. Where are we missing consistency?

logger.error seems redundant then, you can also throw anything. Consistency is lost in how we console out log errors vs exceptions errors, one has a custom format the other is default system format. Not causing a SIGTERM for some console errors makes sense I suppose like in validation so you can collect all the errors before SIGTERM, I just don't understand why they need to look different too?

Copy link
Contributor

@JacobMGEvans JacobMGEvans May 16, 2022

Choose a reason for hiding this comment

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

Wait maybe I missed this,

We log the error to the terminal the error when it gets caught anyway.

All Errors are now passed into the logger.error?

If that is the case ignore everything I said because that is what I was implying we do, one way or another.

EDIT: confirmed in exception handlers the error is passed into logger.error

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@rozenmd could you add a small screenshot of what the error looks like?

Copy link
Contributor Author

@rozenmd rozenmd May 17, 2022

Choose a reason for hiding this comment

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

@threepointone: (using the latest branch preview in this PR)
image

@rozenmd rozenmd merged commit 3545e41 into main May 17, 2022
@rozenmd rozenmd deleted the recommend-node-compat-on-builtin-use branch May 17, 2022 08:14
@github-actions github-actions bot mentioned this pull request May 17, 2022
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.

feat: trying to use node builtins should log a message recommending to try node_compat = true
3 participants