nitrojs / nitrojs/nitro

Unhandled rejection yields 0 exit code during nitro prerendering process

Open
#2,126 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug nuxt v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

Nodejs: 18.18.0
Nitro: 2.8.1
Nuxt: 3.9.3

Reproduction

I don't know how to trigger the error that causes unhandled rejection during nitro prerendering, but I don't think this is important.

Describe the bug

Hello! I'm not sure which exactly this issue is: nuxt, nuxi or nitro. But since the error is originating from nitro/nitro-prerenderer.mjs (although which in turn generated in .nuxt directory) and I see the [nitro] prefix in the logs, I'm reporting it here. I'm sorry in advance if it's not quite the right place.

The issue is that if you run nuxi generate and during the prerendering process an unhandled error is occurred, 0 exit code is returned which is wrong.

Here are some shell logs that showcase the problem:

npx nuxi generate frontend
...

 ERROR  [unhandledRejection] Cannot read properties of undefined (reading 'inTable')                                                                                                                   00:19:43

  at Object.exitCodeText (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
  at compile (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
  at fromMarkdown (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
  at parser (/C:/Users/my-username/<path-to-repo>/node_modules/remark-parse/lib/index.js:18:12)
  at Function.parse (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:668:12)
  at executor (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:734:40)
  at new Promise (<anonymous>)
  at Function.process (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:720:47)
  at parseMarkdown (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2427:41)
  at async Object.parse (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2525:20)


 ERROR  [nitro] [unhandledRejection] Cannot read properties of undefined (reading 'inTable')                                                                                                           00:19:43

  at Object.exitCodeText (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
  at compile (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
  at fromMarkdown (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
  at parser (/C:/Users/my-username/<path-to-repo>/node_modules/remark-parse/lib/index.js:18:12)
  at Function.parse (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:668:12)
  at executor (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:734:40)
  at new Promise (<anonymous>)
  at Function.process (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:720:47)
  at parseMarkdown (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2427:41)
  at async Object.parse (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2525:20)


 ERROR  [unhandledRejection] Cannot read properties of undefined (reading 'inTable')                                                                                                                   00:19:43

  at Object.exitCodeText (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
  at compile (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
  at fromMarkdown (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
  at parser (/C:/Users/my-username/<path-to-repo>/node_modules/remark-parse/lib/index.js:18:12)
  at Function.parse (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:668:12)
  at executor (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:734:40)
  at new Promise (<anonymous>)
  at Function.process (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:720:47)
  at parseMarkdown (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2427:41)
  at async Object.parse (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2525:20)


 ERROR  [nitro] [unhandledRejection] Cannot read properties of undefined (reading 'inTable')                                                                                                           00:19:43

  at Object.exitCodeText (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
  at compile (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
  at fromMarkdown (/C:/Users/my-username/<path-to-repo>/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
  at parser (/C:/Users/my-username/<path-to-repo>/node_modules/remark-parse/lib/index.js:18:12)
  at Function.parse (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:668:12)
  at executor (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:734:40)
  at new Promise (<anonymous>)
  at Function.process (/C:/Users/my-username/<path-to-repo>/node_modules/unified/lib/index.js:720:47)
  at parseMarkdown (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2427:41)
  at async Object.parse (/C:/Users/my-username/<path-to-repo>/frontend/.nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs:2525:20)

$ echo $?
0

(mind the last two lines)

Exactly the same error happened during my CI pipeline and not caused it to fail. I think it would make sense if the process had returned non-zero exit code instead in this case.

Additional context

No response

Logs

No response

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

Start with the nuxi generate entry point and the nitro/nitro-prerenderer.mjs path named in the report; the generated .nuxt/prerender/chunks/nitro/nitro-prerenderer.mjs stack trace shows where the rejection surfaces. Reproduce the unhandled rejection if possible and verify that nuxi generate exits with a non-zero code instead of 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, nuxt, typescript
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.