mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Right now, when doing the following in an Edge API:
```typescript
export default async () => {
await fetch("https://hello.world");
};
```
The stack trace generated does not contain the actual line of code that caused the error.
This gives a bad developer experience when working with `next dev`.
This PR fixes that for this specific use case and adds a test to make sure there's no regression.
For `next start`, there's also a small change, that needs to be pushed upstream to `edge-runtime`.
In order to run user code in the Edge Runtime, we call `vm.evaluate(code: string)`. However,
if we embrace the `options` from the signature of `vm.runInContext(code, ctx, options)`, we can
pass in the filename so the stack trace is correct.
## Bug
- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
8 lines
197 B
JavaScript
8 lines
197 B
JavaScript
import { fetcher } from '../../src/fetcher'
|
|
|
|
export const config = { runtime: 'edge' }
|
|
|
|
export default async function UnknownDomainEndpoint() {
|
|
await fetcher('http://an.unknown.domain.nextjs')
|
|
}
|