This repo contains a reproduction of failing esbuild program deployed to workerd.
Related issues:
- cloudflare/workers-sdk#2029
- cloudflare/workers-sdk#2716
- cloudflare/workerd#210
- cloudflare/workerd#389
- cloudflare/workerd#390
Note that npm-patches/wrangler/esbuild-target.patch
is applied to wrangler via a postinstall
hook to workaround cloudflare/workers-sdk#2716.
git clone git@github.com:IgorMinar/repro-workers-sdk-2029-top-level-await.git
cd repro-workers-sdk-2029-top-level-await
npm install
npm start
# now press 'b' to make a request via a browser
The browser displays: "hello world";
The browser displays: Error: The script will never generate a response.
And the following error is displayed in the terminal:
workerd/io/worker.c++:2461: info: console warning; description = A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
workerd/io/worker.c++:1674: info: uncaught exception; source = Uncaught (in response); exception = Error: The script will never generate a response.
A hanging Promise was canceled. This happens when the worker runtime is waiting for a Promise from JavaScript to resolve, but has detected that the Promise cannot possibly ever resolve because all code and events related to the Promise's I/O context have already finished.
✘ [ERROR] Uncaught (in response) Error: The script will never generate a response.
The issue can be worked around by not using top-level await and instead invoking esbuild initialization from within a request context. See the following diff for a working version of this code: