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

Improve error message #1320

Open
chronark opened this issue Jan 26, 2025 · 2 comments
Open

Improve error message #1320

chronark opened this issue Jan 26, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@chronark
Copy link

What problem will this feature address?

Let me preface this by saying I have no idea if it can be done or how much work it would be, so please feel free to close it.
It's also not really a fumadocs issue but mdx related.

I was writing some markdown and used a < to indicate "less than". It got parsed as a JSX component I think and then threw an error. That's expected I guess, it was just really hard to track down because the reported error was not helpful and didn't point anywhere close to the line the error was on.

The markdown in question:

#### Cons
- Cache invalidation requires communication with all machines or really low TTLs (<10s)
- Inefficient cache refresh patterns
- High load on S3 due to concurrent SWR requests from multiple machines

The error

Failed to compile.

./content/rfcs/0008-dataplane.mdx?collection=rfcs&hash=7915a037b9dbdb5831cc433091db61f8849683859023b6fc77e2bac78d349c36
0008-dataplane.mdx:31:84: Unexpected character `1` (U+0031) before name, expected a character that can start a name, such as a letter, `$`, or `_`

Import trace for requested module:
./content/rfcs/0008-dataplane.mdx?collection=rfcs&hash=7915a037b9dbdb5831cc433091db61f8849683859023b6fc77e2bac78d349c36
./.source/index.js
./app/source.ts
./app/design/layout.tsx


> Build failed because of webpack errors
 ELIFECYCLE  Command failed with exit code 1.

Describe the solution you'd like

Is it possible to detect this kind of error and return a more useful message that points me to the problem?
I guess it has 2 issues right now:

  • The reported line is wrong (probably due to transpilation?)
  • The error message is not helpful if it's pointing to a different line

Describe alternatives you've considered

I removed sections until I narrowed it down, not really fun, don't recommend it.

Additional context

No response

@chronark chronark added the enhancement New feature or request label Jan 26, 2025
@fuma-nama
Copy link
Owner

the line number is actually correct, but since the frontmatter is stripped before passing to MDX compiler, the offset of frontmatter isn't counted. Guess we can replace it to empty lines that can be calculated by the compiler

@chronark
Copy link
Author

aah I see, yeah that checks out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants