@@ -9,22 +9,14 @@ import {
99 setResponseHeaders ,
1010 setResponseStatus ,
1111} from "h3" ;
12- import nodeCrypto from "node:crypto" ;
1312import { readFile } from "node:fs/promises" ;
1413import { resolve , dirname } from "node:path" ;
1514import 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" ;
2017import { SourceMapConsumer } from "source-map" ;
2118import { defineNitroErrorHandler , type InternalHandlerResponse } from "./utils" ;
2219
23- const { Youch, ErrorParser } = _youch as {
24- Youch : { new ( ) : YouchT } ;
25- ErrorParser : { new ( ) : ErrorParserT } ;
26- } ;
27-
2820export default defineNitroErrorHandler (
2921 async function defaultNitroErrorHandler ( error , event ) {
3022 const res = await defaultHandler ( error , event ) ;
@@ -104,11 +96,6 @@ export async function defaultHandler(
10496 headers [ "cache-control" ] = "no-cache" ;
10597 }
10698
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-
11299 // Prepare body
113100 const body = useJSON
114101 ? {
@@ -158,7 +145,7 @@ export async function loadStackTrace(error: any) {
158145 }
159146}
160147
161- type SourceLoader = Parameters < ErrorParserT [ "defineSourceLoader" ] > [ 0 ] ;
148+ type SourceLoader = Parameters < ErrorParser [ "defineSourceLoader" ] > [ 0 ] ;
162149type StackFrame = Parameters < SourceLoader > [ 0 ] ;
163150async function sourceLoader ( frame : StackFrame ) {
164151 if ( ! frame . fileName || frame . fileType !== "fs" || frame . type === "native" ) {
0 commit comments