@@ -9,22 +9,14 @@ import {
9
9
setResponseHeaders ,
10
10
setResponseStatus ,
11
11
} from "h3" ;
12
- import nodeCrypto from "node:crypto" ;
13
12
import { readFile } from "node:fs/promises" ;
14
13
import { resolve , dirname } from "node:path" ;
15
14
import consola from "consola" ;
16
- import type { ErrorParser as ErrorParserT } from "youch-core" ;
17
- import type { Youch as YouchT } from "youch" ;
18
- // @ts -ignore
19
- import * as _youch from "youch-redist" ;
15
+ import { ErrorParser } from "youch-core" ;
16
+ import { Youch } from "youch" ;
20
17
import { SourceMapConsumer } from "source-map" ;
21
18
import { defineNitroErrorHandler , type InternalHandlerResponse } from "./utils" ;
22
19
23
- const { Youch, ErrorParser } = _youch as {
24
- Youch : { new ( ) : YouchT } ;
25
- ErrorParser : { new ( ) : ErrorParserT } ;
26
- } ;
27
-
28
20
export default defineNitroErrorHandler (
29
21
async function defaultNitroErrorHandler ( error , event ) {
30
22
const res = await defaultHandler ( error , event ) ;
@@ -104,11 +96,6 @@ export async function defaultHandler(
104
96
headers [ "cache-control" ] = "no-cache" ;
105
97
}
106
98
107
- // Crypto polyfill for Node.18 (used by youch > @poppinss+dumper)
108
- if ( ! globalThis . crypto && ! useJSON ) {
109
- globalThis . crypto = nodeCrypto as unknown as Crypto ;
110
- }
111
-
112
99
// Prepare body
113
100
const body = useJSON
114
101
? {
@@ -158,7 +145,7 @@ export async function loadStackTrace(error: any) {
158
145
}
159
146
}
160
147
161
- type SourceLoader = Parameters < ErrorParserT [ "defineSourceLoader" ] > [ 0 ] ;
148
+ type SourceLoader = Parameters < ErrorParser [ "defineSourceLoader" ] > [ 0 ] ;
162
149
type StackFrame = Parameters < SourceLoader > [ 0 ] ;
163
150
async function sourceLoader ( frame : StackFrame ) {
164
151
if ( ! frame . fileName || frame . fileType !== "fs" || frame . type === "native" ) {
0 commit comments