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

Uncaught TypeError: Promise.withResolvers is not a function #1167

Closed
olafvanv opened this issue Dec 16, 2024 · 2 comments
Closed

Uncaught TypeError: Promise.withResolvers is not a function #1167

olafvanv opened this issue Dec 16, 2024 · 2 comments

Comments

@olafvanv
Copy link

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [ x] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

Description

I'm getting the error 'Uncaught TypeError: Promise.withResolvers is not a function' when opening a PDF. I'm using Angular 18 in combination with ng2-pdf-viewer 10.3.4.

Not sure if I should raise the issue here, since the error is thrown from the pdf.worker.min.mjs file, but I'm using the PDF worker file locally (application doesn't have internet access) from the installed pdfjs-dist library (v4.6.82) like this:

// angular.json
...
"assets": [
  { "glob": "pdf.worker.min.mjs", "input": "node_modules/pdfjs-dist/build", "output": "/assets/js/"}
]
...

And then inside the component where I use the pdf-viewer:

constructor() {
  (window as any).pdfWorkerSrc = 'assets/js/pdf.worker.min.mjs';
}

This has worked for all older versions, but since the upgrade to 10.3 it throws the error above.

What I can find about this error is that it has to do with the node version and that the .withResolvers() is only available with node >v22. I'm using node v20.18.1, which is supported by Angular. Shouldn't this library support all node versions Angular is support as well?

I also see that v10.4.0 is breaking on Angular 18 because of the typescript version Angular 18 is depending on (setIterator error -> #1164). These are breaking changes inside minor upgrades of the library.
Is it an idea to create versions of this library based on the Angular version it is tested/built with?

Workaround

Right now if I downgrade to ng2-pdf-viewer ~10.2.0 it works, this version is using pdfjs-dist 3.11.174 where the .withResolvers() is not yet implemented. This is implemented from version 4.1.392.

@shamoon
Copy link
Contributor

shamoon commented Dec 16, 2024

I suspect this is an issue on your end with dependencies, perhaps not having a clean package lock kind of thing. This issue was 'polyfilled' in #1128 (basically the whole point of that PR was to allow upgrading pdfjs that way).

And yea, has nothing to do with 10.4

@olafvanv
Copy link
Author

Thanks for your reply.

I think the issue lays with the browser version used on the system of the application. I've tried to isolate the issue on a different machine (with the latest version of Chrome) and I have no issues using the library as described, so this is indeed a non-issue and can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants