Skip to content

fix: check type before using string-only method #2393

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

Merged
merged 10 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
with:
deno-version: v1.x
- name: Install netlify-cli and npm
run: npm install -g netlify-cli npm
run: npm install -g netlify-cli npm@10.2.4
- name: NPM Install
run: npm install
- name: Run integration tests
Expand Down
10 changes: 6 additions & 4 deletions packages/runtime/src/templates/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,12 @@ export const augmentFsModule = ({

// ...then monkey-patch it to see if it's requesting a CDN file
promises.readFile = (async (file, options) => {
const baseUrl = getBase()

// We only care about page files
if (file.startsWith(pageRoot)) {
// file argument can be a string, URL, etc - Next.js cache reading uses a string
// and that's only thing we really want to handle here, so we just do type checking
// instead of trying to handle all possible type before checking weather read
// is about page files.
if (typeof file === 'string' && file.startsWith(pageRoot)) {
const baseUrl = getBase()
// We only want the part after `.next/server/`
const filePath = file.slice(pageRoot.length + 1)

Expand Down