Skip to content

Commit 06f0e0c

Browse files
authored
fix: check type before using string-only method (#2393)
* Update handlerUtils.ts * Create .nvmrc * Update handlerUtils.ts * Update handlerUtils.ts * maybe downgrade cli? * chore: remove nvmrc * Revert "maybe downgrade cli?" This reverts commit 42d8ff9. * chore: ? * chore: how about different cli? * chore: remove test debug code
1 parent 0b464ca commit 06f0e0c

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.github/workflows/test-integration.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
deno-version: v1.x
3030
- name: Install netlify-cli and npm
31-
run: npm install -g netlify-cli npm
31+
run: npm install -g netlify-cli npm@10.2.4
3232
- name: NPM Install
3333
run: npm install
3434
- name: Run integration tests

packages/runtime/src/templates/handlerUtils.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ export const augmentFsModule = ({
135135

136136
// ...then monkey-patch it to see if it's requesting a CDN file
137137
promises.readFile = (async (file, options) => {
138-
const baseUrl = getBase()
139-
140-
// We only care about page files
141-
if (file.startsWith(pageRoot)) {
138+
// file argument can be a string, URL, etc - Next.js cache reading uses a string
139+
// and that's only thing we really want to handle here, so we just do type checking
140+
// instead of trying to handle all possible type before checking weather read
141+
// is about page files.
142+
if (typeof file === 'string' && file.startsWith(pageRoot)) {
143+
const baseUrl = getBase()
142144
// We only want the part after `.next/server/`
143145
const filePath = file.slice(pageRoot.length + 1)
144146

0 commit comments

Comments
 (0)