facebook / facebook/docusaurus
Poor stack traces in SSR
- Dominant language
- TypeScript
- Stars
- 66.2k
- Forks
- 10k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 52
Description
### Have you read the Contributing Guidelines on issues?
- [X] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#reporting-new-issues).
### Motivation
Our SSR errors are undebuggable. For example, https://github.com/facebook/docusaurus/issues/7398, https://github.com/facebook/docusaurus/issues/4268.
If a piece of code accesses `window`, all we know is which path is currently being rendered, but if this code is a client module, then it throws on every single path. Beyond that, when you look into the stack, it, at most, shows something like
```
Hook useTabGroupChoice is called outside the .
ReactContextError
at useTabGroupChoice (main:38645:1282)
at ResponseCodeTabs (main:56136:584)
at d (main:118177:498)
at bb (main:118180:16)
at a.b.render (main:118186:43)
at a.b.read (main:118185:83)
at Object.exports.renderToString (main:118196:138)
at doRender (main:29440:417)
at async serverEntry_render (main:29437:290)
```
Which isn't really telling us anything.
I don't really know what we need to do specifically to fix this: do we use source maps? Do we do SSR in development mode so that React can give us the component stack? Or do we simply wrap some imports in `try`/`catch` (I'm thinking specifically about the client modules)?
### Self-service
- [ ] I'd be willing to do some initial work on this proposal myself.
Contributor guide
Assessment
This issue has not been assessed yet.