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: eager loading of wasm in jest environment #1246

Merged
merged 1 commit into from Mar 4, 2022

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Feb 22, 2022

fixes #1235

Its pretty horrible, and but really need a solution to this problem.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina
Copy link
Member

Can you add a simple test with Jest?

lib/client.js Outdated Show resolved Hide resolved
lib/client.js Outdated Show resolved Hide resolved
Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

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

See suggestions. Needs to work on node 12.

@mcfedr mcfedr force-pushed the jest-fix branch 3 times, most recently from 4d77a03 to 845c757 Compare February 22, 2022 13:39
package.json Outdated
@@ -48,7 +48,7 @@
"test": "npm run test:tap && npm run test:node-fetch && npm run test:fetch && npm run test:jest && tsd",
"test:node-fetch": "node scripts/verifyVersion.js 16 || mocha test/node-fetch",
"test:fetch": "node scripts/verifyVersion.js 16 || tap test/fetch/*.js",
"test:jest": "jest test/jest/test",
"test:jest": "jest test/jest/*.js",
Copy link
Contributor Author

@mcfedr mcfedr Feb 22, 2022

Choose a reason for hiding this comment

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

@mcollina found there was a test file, mock-agent.test.js, for jest, that had been disabled, and by changing this and it running, we actually see this error, and with this fix its resolved

@mcfedr mcfedr requested a review from ronag February 22, 2022 13:43
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@@ -408,6 +408,8 @@ const constants = require('./llhttp/constants')
const EMPTY_BUF = Buffer.alloc(0)

async function lazyllhttp () {
const llhttpWasmData = process.env.JEST_WORKER_ID ? require('./llhttp/llhttp.wasm.js') : undefined
Copy link
Member

Choose a reason for hiding this comment

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

Now I don't understand? What's the purpose? This isn't very eager.

@mcfedr
Copy link
Contributor Author

mcfedr commented Feb 22, 2022

@ronag I agree, its not very clear to be exactly whats causing this, but after the first version, i thought, lets just try this, and works fine in the projects that failed. I guess its related to doing require inside the catch block.

@mcfedr
Copy link
Contributor Author

mcfedr commented Feb 22, 2022

I guess im done changing it, the last change got windows to find the tests, looks like wont run on macos because of my access level, but i've run it on macos myself

@mcollina mcollina merged commit 38eabc9 into nodejs:main Mar 4, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
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.

ReferenceError: You are trying to import a file after the Jest environment has been torn down.
3 participants