-
Notifications
You must be signed in to change notification settings - Fork 170
Closed
Description
There is an issue in code:
https://github.com/opennextjs/opennextjs-aws/blob/main/packages/open-next/src/build/createAssets.ts
Code like:
Object.entries(cacheFilesPath).forEach(([cacheFilePath, files]) => {
const cacheFileMeta = files.meta
? JSON.parse(fs.readFileSync(files.meta, "utf8"))
: undefined;
//...
});
is failing because of unsafe JSON parsing - whenever Next.js creates a file in cache that is not valid JSON file, deployment of OpenNext fails with:
SyntaxError: Unexpected non-whitespace character after JSON at position 34335
at JSON.parse (<anonymous>)
at file:///app/node_modules/@opennextjs/aws/dist/build/createAssets.js:141:35
at file:///app/node_modules/@opennextjs/aws/dist/build/helper.js:159:13
at Array.forEach (<anonymous>)
at Module.traverseFiles (file:///app/node_modules/@opennextjs/aws/dist/build/helper.js:151:51)
at createCacheAssets (file:///app/node_modules/@opennextjs/aws/dist/build/createAssets.js:139:21)
at build (file:///app/node_modules/@opennextjs/cloudflare/dist/cli/build/build.js:59:44)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async buildCommand (file:///app/node_modules/@opennextjs/cloudflare/dist/cli/commands/build.js:13:5)
(The fact that Next.js generates incorrect JSON file in data cache is other problem, but not a subject of this ticket).
The goal of this ticket is to request fix in the way JSON is being parsed in mentioned createAssets.ts file.
khuezy and sommeeeer
Metadata
Metadata
Assignees
Labels
No labels