repack
repack copied to clipboard
Promise may not be fulfilled with 'undefined' when statusCode is not 204
Environment
react-native 0.64.2 @callstack/repack 2.5.1
Description
I seem to get this error a lot and I'm not sure why, as there's no other information. It only happens when bundling ios, not android. Here's the full console log.
ℹ [21:46:13.025Z][DevServerProxy] Starting compiler worker { platform: 'ios', port: 64743 }
ℹ [21:46:13.074Z][DevServerProxy] Hermes device connected { deviceId: 2 }
ℹ [21:46:14.087Z][DevServer@ios] Server listening at http://[::]:64743
ℹ [21:46:14.088Z][DevServerProxy] fetching from remote server {
source: 'http://localhost:64743/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.coinbase.OnboardingMobile'
}
ℹ [21:46:14.094Z][DevServerProxy] fetching from remote server { source: 'http://localhost:64743/api/dashboard/stats?platform=ios' }
ℹ [21:46:14.129Z][webpack-dev-middleware] wait until bundle finished: /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.coinbase.OnboardingMobile
ℹ [21:46:14.130Z][DevServer@ios] Dashboard client connected { clientId: 'client#0' }
ℹ [21:46:14.132Z][webpack-dev-middleware] wait until bundle finished: /api/dashboard/stats?platform=ios
✖ [21:47:13.971Z][DevServerProxy] Promise may not be fulfilled with 'undefined' when statusCode is not 204 {
err: {
type: 'FastifyError',
message: "Promise may not be fulfilled with 'undefined' when statusCode is not 204",
stack: "FastifyError: Promise may not be fulfilled with 'undefined' when statusCode is not 204\n" +
' at /Users/milesjohnson/Projects/react-native/node_modules/fastify/lib/wrapThenable.js:30:30',
name: 'FastifyError',
code: 'FST_ERR_PROMISE_NOT_FULFILLED',
statusCode: 500
}
}
Reproducible Demo
Does this happen on a fresh project as well?
No, just ours. I think our project may be too big. With metro, our bundle is 25mb+. When trying to use repack, our bundle is about 50mb, and almost always runs out of memory while trying to bundle.
Also happening in one of my project. The bundle size is big for me too.
Same issue here
me too, I refresh the project and this run ok
Any clue on how ti solve this bug.? Any help would be appreciated
Unfortunately, I don't have any clues. Unless someone provides a reproduction project and I can use, the chances of fixing it are slim.
This happens to me also on our relatively large project but I don't run out of memory. It seems like a timeout is being hit in the dev server as the build process continues (as seen in the dashboard). When I wait for the build to finish and reload the app everything is "fine". (quotes because I have issues with some modules, will create a separate issue for these)
This case might be simple to fix by removing/extending a timeout?
This case might be simple to fix by removing/extending a timeout?
It's worth a shot. I can provide a diff what to edit and alter the timeout and I'd appreciate if someone can apply it and see if the issue still persists.
Sure, I can try this on our codebase 👍
Just to note tho, we're not currently running repack in production. It's only implemented on a WIP/POC branch right now.
Ok I think I found a solution.
I've checked the code and the timeout is set for 5mins so it's not the timeout inside Re.Pack than might be causing the issue, but then I've added short timeout to the request for a bundle: curl "http://localhost:8081/index.bundle?platform=ios" --max-time 10
- the bundle compilation takes around 20+s in TesterApp so curl
should terminate the connection due to timeout and it did and I was finally able to see the infamous Promise may not be fulfilled with 'undefined' when statusCode is not 204
.
As for the solution:
Could someone add return reply;
to the end of the forwardRequest
(line 234) function inside node_modules/@callstack/repack/dist/server/DevServerProxy.js
:
async forwardRequest(platform, request, reply) {
if (!this.workers[platform]) {
await this.runWorker(platform);
}
const {
port
} = await this.workers[platform];
const host = request.headers[':authority'] || request.headers.host;
const url = request.headers[':path'] || request.raw.url;
if (!url || !host) {
reply.code(500).send();
} else {
const compilerWorkerUrl = `http://localhost:${port}${url}`;
this.fastify.log.debug({
msg: 'Fetching from worker',
url: compilerWorkerUrl,
method: request.method,
body: request.body
});
reply.from(compilerWorkerUrl);
}
+ return reply;
}
@zamotany This didn't fix it for me unfortunately, i receive the exact same error.
Ok I think I found a solution.
I've checked the code and the timeout is set for 5mins so it's not the timeout inside Re.Pack than might be causing the issue, but then I've added short timeout to the request for a bundle:
curl "http://localhost:8081/index.bundle?platform=ios" --max-time 10
- the bundle compilation takes around 20+s in TesterApp socurl
should terminate the connection due to timeout and it did and I was finally able to see the infamousPromise may not be fulfilled with 'undefined' when statusCode is not 204
.As for the solution: Could someone add
return reply;
to the end of theforwardRequest
(line 234) function insidenode_modules/@callstack/repack/dist/server/DevServerProxy.js
:async forwardRequest(platform, request, reply) { if (!this.workers[platform]) { await this.runWorker(platform); } const { port } = await this.workers[platform]; const host = request.headers[':authority'] || request.headers.host; const url = request.headers[':path'] || request.raw.url; if (!url || !host) { reply.code(500).send(); } else { const compilerWorkerUrl = `http://localhost:${port}${url}`; this.fastify.log.debug({ msg: 'Fetching from worker', url: compilerWorkerUrl, method: request.method, body: request.body }); reply.from(compilerWorkerUrl); } + return reply; }
returning the reply works for me!
This issue has been marked as stale because it has been inactive for 30 days. Please update this issue or it will be automatically closed in 14 days.
This issue has been automatically closed because it has been inactive for more than 14 days. Please reopen if you want to add more context.