Skip to content

Commit 1dd6547

Browse files
authored
Fix consumption from Next.js client components (#464)
Apparently, `process` exists but `.versions.node` does not. Next.js may be doing something weird with `process` so we'll just be more cautious when testing for Node.js v18 in the `fetch` polyfill.
1 parent b2901eb commit 1dd6547

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/olive-pandas-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hibp': patch
3+
---
4+
5+
Fix consumption from Next.js client components.

src/api/fetch-polyfill.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable global-require */
22
/* eslint-disable @typescript-eslint/no-var-requires */
33
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
4+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
45

56
// This can probably be removed in favor of Node's native fetch once we drop
67
// support for v18. https://x.com/ebey_jacob/status/1709975146939973909?s=20
@@ -9,7 +10,7 @@
910
export function installUndiciOnNode18() {
1011
if (
1112
typeof process !== 'undefined' &&
12-
process.versions.node.startsWith('18.')
13+
process.versions?.node?.startsWith('18.')
1314
) {
1415
const {
1516
File: UndiciFile,

0 commit comments

Comments
 (0)