sst / open-next

Open source Next.js serverless adapter
https://open-next.js.org
MIT License
3.7k stars 111 forks source link

open-next errors out on some favicon formats. #390

Closed bebbi closed 3 months ago

bebbi commented 3 months ago

npx --yes open-next@3.0.0-rc.5 build fails in my next project because I used a

icon.tsx as favicon per the documentation Removing icon.tsx and adding icon.png worked around the issue. (As a note, icon.tsx worked in dev mode and showed a favicon as expected.

Error:

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
node:fs:456
    return binding.readFileUtf8(path, stringToFlags(options.flag));
                   ^

Error: ENOENT: no such file or directory, open '/Users/bebbi/code/landing/.next/standalone/.next/server/app/icon/route.js.nft.json'
    at readFileSync (node:fs:456:20)
    at computeCopyFilesForPage (file:///Users/bebbi/.npm/_npx/243dd04f789c84f7/node_modules/open-next/dist/build/copyTracedFiles.js:39:42)

Possibly some relation to #335 This came from this sst v3 issue

conico974 commented 3 months ago

The issue here is likely that you use export const runtime = "edge". In V3 edge runtime needs to be in their own separate function and cannot be bundled inside of the default server or any node server function. (To be fair, there is only downsides in bundling a fake edge runtime into the default server) We need to add a specific error here. Could you try without this line ?

bebbi commented 3 months ago

I've deployed it using only a call to

    const site = new sst.aws.Nextjs('Web', { domain: myDomain })  // sst ion 0.0.131

without any options in an sst.config.ts for the ion next config so I'm not sure how to act on this.

conico974 commented 3 months ago

I'm not talking about the ion next config, i'm talking about the icon.tsx file. If you have this line export const runtime = "edge" inside this file, you need to remove it. The edge runtime is useless outside of vercel or without some advanced config in open-next.config.ts

If you want more info about the open next config file you can take a look here. Just so you know, not every feature of open-next is supported in ion. (At the moment only lambda & lambda@edge are supported)

bebbi commented 3 months ago

Oh sorry, I didn't realize I'd copied this from the doc example. Without the line, and with an icon.tsx, everything works 👍, thanks! Probably a specific error would help, so I'm letting the closing up to you in case you wanted this issue to track that.

conico974 commented 3 months ago

The specific error has been added in open-next@3.0.0-rc.9. At the moment we're on 3.0.0-rc.11