QwikDev / QwikDev/qwik

[🐞][Netlify] :: Qwik Edge Functions bundling qwik-city-not-found-paths

Open
#8,457 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug router
Dominant language
TypeScript
Stars
22.1k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
52

Description

Which component is affected?

Qwik Runtime

Describe the bug

I created a new qwik app npm create qwik@latest and then I tried to deploy it to netlify using npm run qwik add netlify-edge, once is desployed netlify is throwing this error:

3:17:55 PM: Edge Functions bundling                                       
3:17:55 PM: ────────────────────────────────────────────────────────────────
3:17:55 PM: ​
3:17:55 PM: Packaging Edge Functions from .netlify/edge-functions directory:
3:17:55 PM:  - entry.netlify-edge
3:17:55 PM: No Edge Functions were found in netlify/edge-functions directory
3:17:56 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
3:17:56 PM: node:internal/process/promises:394
3:17:56 PM:     triggerUncaughtException(err, true /* fromPromise */);
3:17:56 PM:     ^
3:17:56 PM: [Error: ENOENT: no such file or directory, stat '/tmp/tmp-2553-zHlYx4cPX0d3/qwik-city-not-found-paths.js'] {
3:17:56 PM:   errno: -2,
3:17:56 PM:   code: 'ENOENT',
3:17:56 PM:   syscall: 'stat',
3:17:56 PM:   path: '/tmp/tmp-2553-zHlYx4cPX0d3/qwik-city-not-found-paths.js'
3:17:56 PM: }

Netlify's edge bundler processes files from .netlify/edge-functions/entry.netlify-edge/ by copying them to a /tmp directory. During this process it strips the @ prefix from filenames, but the built entry.netlify-edge.js contains imports referencing the original @-prefixed names:

import { getNotFound } from "./@qwik-city-not-found-paths.js";
import { isStaticPath } from "./@qwik-city-static-paths.js";
import Oe from "./@qwik-city-plan.js";

So the bundler would copy @qwik-city-not-found-paths.js β†’ qwik-city-not-found-paths.js in /tmp, then fail trying to resolve the import because the import still referenced @qwik-city-not-found-paths.js.

I added a postbuild script that fixed the issue, but the root cause still there

import { readFileSync, writeFileSync, readdirSync, copyFileSync } from 'fs';
import { join } from 'path';

const dir = '.netlify/edge-functions/entry.netlify-edge';
const entry = join(dir, 'entry.netlify-edge.js');

// Rewrite all @-prefixed imports to non-@ versions
let content = readFileSync(entry, 'utf8');
content = content.replaceAll('"./@', '"./');
writeFileSync(entry, content);

// Copy all @-prefixed files to non-@ versions
readdirSync(dir)
  .filter(f => f.startsWith('@'))
  .forEach(f => copyFileSync(join(dir, f), join(dir, f.slice(1))));

// Copy client manifest so the edge function can resolve QRL symbols
copyFileSync('dist/q-manifest.json', join(dir, 'q-manifest.json'));

console.log('postbuild: patched @ imports and copied manifest successfully');

I talked to the Netlify team and they said they won't fix it on their end, here their response:

this is more likely something that needs to be addressed in the Qwik City adapter (avoiding @-prefixed filenames or adjusting imports), rather than in the bundler itself. We can still flag this internally as a potential improvement, but we can’t guarantee changes on the bundler side.

...For your question about @prefixes, the bundler normalizes filenames to keep builds consistent and portable. As part of that, characters like @ can get stripped, not because they’re special, but because they may conflict with internal naming, module resolution or cross-platform safety.

For deeper insight or a long-term fix, it would be best to coordinate with the Qwik City adapter team, as mentioned earlier.

Reproduction

https://github.com/garciadiazjaime/website-artic-v2

Steps to reproduce

from package.json remove the script "postbuild": "node scripts/postbuild.mjs" then deploy the app to Netlify

Build command
npm run build

Publish directory
dist

Functions directory
netlify/functions

System Info
System:
    OS: macOS 15.7.3
    CPU: (14) arm64 Apple M4 Pro
    Memory: 95.84 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.20.1 - /Users/.../.nvm/versions/node/v20.20.1/bin/node
    npm: 10.8.2 - /Users/.../.nvm/versions/node/v20.20.1/bin/npm
  Browsers:
    Brave Browser: 146.1.88.127
    Chrome: 146.0.7680.154
    Safari: 26.2
  npmPackages:
    @builder.io/qwik: ^1.19.2 => 1.19.2
    @builder.io/qwik-city: ^1.19.2 => 1.19.2
    typescript: 5.4.5 => 5.4.5
    undici: * => 7.24.3
    vite: 7.3.1 => 7.3.1
Additional Information

qwik rocks! thanks for the help

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up β€” it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the deployment without the postbuild script, then inspect .netlify/edge-functions/entry.netlify-edge/entry.netlify-edge.js and the generated @-prefixed files. Compare the imports with the filenames copied into Netlify's temporary directory; done means a standard npm run build deployment succeeds without the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.