ComponentizeJS icon indicating copy to clipboard operation
ComponentizeJS copied to clipboard

Calls to setTimeout during initialization cause build to fail

Open brettkolodny opened this issue 6 months ago • 2 comments

I'm attempting to build some code using the pdfkit library and after replacing any APIs that are not currently supported I'm met with the following error:

Exception while evaluating top-level script
pdfkit.js:29390:26 TypeError: setTimeout can only be used during request handling, not during initialization
Additionally, some promises were rejected, but the rejection never handled:
Promise rejected but never handled: setTimeout can only be used during request handling, not during initialization
Stack:
  dew$28/FSWatcher2/[email protected]:29390:26
  dew$28/[email protected]:29498:30
  dew$28/[email protected]:29065:17
  [email protected]:29594:7
  node_modules/.pnpm/@[email protected]/node_modules/@jspm/core/nodelibs/browser/[email protected]:29756:14
  [email protected]:14:56
  @pdfkit.js:42457:1

This can be reproduced by cloning my test repo and running the following command:

pnpm install --frozen-lockfile
pnpm build:pdf-kit

brettkolodny avatar Jul 09 '25 14:07 brettkolodny

Hey @brettkolodny just checking here but were you able to get by this by moving the initialization code to somewhere during the running request/exported functions instead?

vados-cosmonic avatar Jul 22 '25 23:07 vados-cosmonic

I haven't played around with the code since making this issue. And by "moving the initialization code to somewhere during the running request/exported functions instead" do you mean wrapping the code in essentially another function? I'd have to double check but I believe that a lot of this code may be, unfortunately, running on import. Are dynamic imports supported?

brettkolodny avatar Aug 04 '25 12:08 brettkolodny