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

TypeError: Promise.withResolvers is not a function #76

Closed
sirkitree opened this issue Oct 29, 2024 · 4 comments
Closed

TypeError: Promise.withResolvers is not a function #76

sirkitree opened this issue Oct 29, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@sirkitree
Copy link
Collaborator

From an off comment in #47 (comment) from https://github.com/adnanmirza1

Describe the bug

Hello @sirkitree, hope you'll be fine. Sorry for being off the topic but I need help setting up this project on my linux machine, I added env's, node v 20.13.1, runned npm i which was successful, and now after node --loader ts-node/esm src/index.ts
I'm seeing below error.
image

@sirkitree
Copy link
Collaborator Author

@adnanmirza1 can you please add step to reproduce this bug reliably?

@sirkitree sirkitree self-assigned this Oct 31, 2024
@sirkitree
Copy link
Collaborator Author

I'm now experiencing this.

This error occurs because Promise.withResolvers() is a relatively new feature that isn't available in Node.js v20.18.0.

We have a few options to fix this:

  1. Upgrade to Node.js v21.0.0 or later where Promise.withResolvers() is supported
  2. Use an older version of pdfjs-dist that doesn't use this feature. You can modify your package.json
  3. Create a polyfill for Promise.withResolvers(). You would need to add this before importing pdfjs-dist

I think we should go with option 1.

@sirkitree
Copy link
Collaborator Author

Tested this PR and it works - do you want to give it a shot @adnanmirza1 ?

@adnanmirza1
Copy link

thanks @sirkitree, I just cloned it followed the steps from readme, installed the packages using npm i, (node version 20.13.1).
After this I started the project using command npm run start and got this Promise.withResolvers error.
I did some search and added polyfill and the issue was solved using the guides from issue
wojtekmaj/react-pdf#1811

then after some time I simply updated the node version to 22.10.0 using nvm and the issue was solved even without the polyfill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants