Skip to content

Commit

Permalink
fix: rename .wasm to -wasm to appease jest (nodejs#2064)
Browse files Browse the repository at this point in the history
* fix: rename .wasm to -wasm to appease jest

* fix: use local server for redirect node-fetch test
  • Loading branch information
KhafraDev authored and crysmags committed Feb 27, 2024
1 parent e975645 commit d836878
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions build/wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ execSync(`${WASI_ROOT}/bin/clang \

const base64Wasm = readFileSync(join(WASM_OUT, 'llhttp.wasm')).toString('base64')
writeFileSync(
join(WASM_OUT, 'llhttp.wasm.js'),
join(WASM_OUT, 'llhttp-wasm.js'),
`module.exports = "${base64Wasm}";\n`
)

Expand Down Expand Up @@ -74,6 +74,6 @@ execSync(`${WASI_ROOT}/bin/clang \

const base64WasmSimd = readFileSync(join(WASM_OUT, 'llhttp_simd.wasm')).toString('base64')
writeFileSync(
join(WASM_OUT, 'llhttp_simd.wasm.js'),
join(WASM_OUT, 'llhttp_simd-wasm.js'),
`module.exports = "${base64WasmSimd}";\n`
)
6 changes: 3 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,19 @@ const createRedirectInterceptor = require('./interceptor/redirectInterceptor')
const EMPTY_BUF = Buffer.alloc(0)

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

let mod
try {
mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd.wasm.js'), 'base64'))
mod = await WebAssembly.compile(Buffer.from(require('./llhttp/llhttp_simd-wasm.js'), 'base64'))
} catch (e) {
/* istanbul ignore next */

// We could check if the error was caused by the simd option not
// being enabled, but the occurring of this other error
// * https://github.com/emscripten-core/emscripten/issues/11495
// got me to remove that check to avoid breaking Node 12.
mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || require('./llhttp/llhttp.wasm.js'), 'base64'))
mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || require('./llhttp/llhttp-wasm.js'), 'base64'))
}

return await WebAssembly.instantiate(mod, {
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions test/node-fetch/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1648,15 +1648,15 @@ describe('node-fetch', () => {

it('should allow manual redirect handling', function () {
this.timeout(5000)
const url = 'https://httpbin.org/status/302'
const url = `${base}redirect/302`
const options = {
redirect: 'manual'
}
return fetch(url, options).then(res => {
expect(res.status).to.equal(302)
expect(res.url).to.equal(url)
expect(res.type).to.equal('basic')
expect(res.headers.get('Location')).to.equal('/redirect/1')
expect(res.headers.get('Location')).to.equal('/inspect')
expect(res.ok).to.be.false
})
})
Expand Down

0 comments on commit d836878

Please sign in to comment.