Skip to content
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

Error when deploying to Vercel: ENXIO: no such device or address, open '/dev/tty' #7564

Closed
1 task
Lifeni opened this issue Jul 4, 2023 · 1 comment · Fixed by #8039
Closed
1 task

Error when deploying to Vercel: ENXIO: no such device or address, open '/dev/tty' #7564

Lifeni opened this issue Jul 4, 2023 · 1 comment · Fixed by #8039
Labels
feat: ssr Related to SSR (scope) pkg: vercel Related to Vercel adapter (scope)

Comments

@Lifeni
Copy link
Contributor

Lifeni commented Jul 4, 2023

What version of astro are you using?

@astrojs/vercel: 3.6.0, astro: 2.7.3

Are you using an SSR adapter? If so, which one?

Vercel

What package manager are you using?

pnpm

What operating system are you using?

Vercel Deployments, WSL

What browser are you using?

None

Describe the Bug

One of the paths on my site is /dev, like this: example.org/dev. When I try to deploy to Vercel using the @astrojs/vercel package, the following error is reported.

[22:26:20.051] Running build in Cleveland, USA (East) – cle1
[22:26:20.117] Cloning github.com/XXXX (Branch: main, Commit: XXXX)
[22:26:20.357] Previous build cache not available
[22:26:20.465] Cloning completed: 347.747ms
[22:26:20.588] Running "vercel build"
[22:26:21.114] Vercel CLI 31.0.1
[22:26:21.669] Installing dependencies...
[22:26:27.333] 
[22:26:27.333] added 478 packages in 5s
[22:26:27.334] 
[22:26:27.334] 175 packages are looking for funding
[22:26:27.334]   run `npm fund` for details
[22:26:27.355] Detected `package-lock.json` generated by npm 7+...
[22:26:27.355] Running "npm run build"
[22:26:27.664] 
[22:26:27.664] > @example/basics@0.0.1 build
[22:26:27.664] > astro build
[22:26:27.664] 
[22:26:28.826] 02:26:28 PM [content] No content directory found. Skipping type generation.
[22:26:28.827] 02:26:28 PM [build] output target: server
[22:26:28.827] 02:26:28 PM [build] deploy adapter: @astrojs/vercel/serverless
[22:26:28.828] 02:26:28 PM [build] Collecting build info...
[22:26:28.828] 02:26:28 PM [build] Completed in 73ms.
[22:26:28.829] 02:26:28 PM [build] Building server entrypoints...
[22:26:30.072] 02:26:30 PM [build] Completed in 1.24s.
[22:26:30.084] 
[22:26:30.084]  finalizing server assets 
[22:26:30.084] 
[22:26:30.084] 02:26:30 PM [build] Rearranging server assets...
[22:26:30.511]  error   ENXIO: no such device or address, open '/dev/tty'
[22:26:30.511] Error: ENXIO: no such device or address, open '/dev/tty'

The build step keeps getting stuck on this error and doesn't stop.

If you delete the /dev path, or rename it to /dev1, it will not report an error and the site will deploy properly.

If you run npm run build locally or on stackblitz, no errors will be reported.

What's the expected result?

The site should be deployed successfully, and the following is the successful log output.

...
[22:09:12.177] 
[22:09:12.177]  finalizing server assets 
[22:09:12.177] 
[22:09:12.177] 02:09:12 PM [build] Rearranging server assets...
[22:09:12.186] 
[22:09:14.980] 02:09:14 PM [build] Server built in 5.29s
[22:09:14.980] 02:09:14 PM [build] Complete!
[22:09:15.079] Build Completed in /vercel/output [8s]
[22:09:15.198] Deploying outputs...
[22:09:18.854] Deployment completed
[22:09:23.210] Uploading build cache [27.45 MB]...
[22:09:24.369] Build cache uploaded: 1.158s

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-vercel-dev-path?file=src%2Fpages%2Fdev%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@ematipico ematipico added the pkg: vercel Related to Vercel adapter (scope) label Jul 4, 2023
@Lifeni
Copy link
Contributor Author

Lifeni commented Jul 8, 2023

This problem also occurs on Linux (WSL) and also reports errors for paths like /etc.

I found a temporary workaround, probably a bug in the package @vercel/nft.

  1. Patch the package with pnpm patch @vercel/nft.
  2. Open the temp package dir in the terminal.
  3. Find /out/node-file-trace.js and add the following line of code at line 310.
  4. Run the pnpm patch-commit <temp-package-dir> prompted in the terminal before to apply the patch.
        const { deps, imports, assets, isESM } = analyzeResult;
        if (isESM) {
            this.esmFileList.add((0, path_1.relative)(this.base, path));
        }
        await Promise.all([
            ...[...assets].map(async (asset) => {
                // patch
+               if (asset.startsWith('/dev')) return;
                
                const ext = (0, path_1.extname)(asset);
                if (ext === '.js' || ext === '.mjs' || ext === '.node' || ext === '' ||
                    this.ts && (ext === '.ts' || ext === '.tsx') && asset.startsWith(this.base) && asset.slice(this.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1)
                    await this.emitDependency(asset, path);
                else
                    await this.emitFile(asset, 'asset', path);
            }),
            ...[...deps].map(async (dep) => this.maybeEmitDep(dep, path, !isESM)),
            ...[...imports].map(async (dep) => this.maybeEmitDep(dep, path, false)),
        ]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: ssr Related to SSR (scope) pkg: vercel Related to Vercel adapter (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants