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: Cannot read properties of undefined (reading 'startsWith') #463

Closed
PodStuart opened this issue Apr 29, 2024 · 4 comments · Fixed by #464
Closed

TypeError: Cannot read properties of undefined (reading 'startsWith') #463

PodStuart opened this issue Apr 29, 2024 · 4 comments · Fixed by #464

Comments

@PodStuart
Copy link

Since v14.1.0 we have started seeing an error occurring at

process.versions.node.startsWith('18.')
.

Debugging through I can see that process is actually defined when this code executes. I think perhaps this could be a Next.js thing but I am not totally sure. We call hibp from the browser I should add.

I wonder if using typeof window === 'undefined' rather than typeof process !== 'undefined' might be an approach which would have the same effect but not impact on Next.js users.

Thanks.

@wKovacs64
Copy link
Owner

Hmm, I tested this in a vanilla Vite app and a Remix app and it worked fine, so I agree this may be a Next.js specific issue. I'll try to reproduce it here in a bit. They probably do something weird to process - we might be able to hack around it with optional chaining.

We used the window check previously, but that is flawed as it prevents usage in web workers and extension background threads.

@wKovacs64
Copy link
Owner

hibp v14.1.1 should resolve your issue @PodStuart. I confirmed the problem and this solution in fresh Pages Router and App Router projects. Sorry about the hassle and thanks for reporting it!

@all-contributors please add @PodStuart for bug report

Copy link
Contributor

@wKovacs64

I couldn't determine any contributions to add, did you specify any contributions?
Please make sure to use valid contribution names.

I've put up a pull request to add @PodStuart! 🎉

@PodStuart
Copy link
Author

Thank you for lightning fast resolution much appreciated.

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

Successfully merging a pull request may close this issue.

2 participants