aboutsummaryrefslogtreecommitdiff
path: root/src/js/_codegen/client-js.ts
diff options
context:
space:
mode:
authorGravatar dave caruso <me@paperdave.net> 2023-09-28 03:53:24 -0700
committerGravatar GitHub <noreply@github.com> 2023-09-28 03:53:24 -0700
commit387f1260c9dc0cea667b44ec0152fff0cd4def25 (patch)
tree24dde83cf812481b6d1c8de316a30ece7b745a54 /src/js/_codegen/client-js.ts
parente60b3607c12c91959ec795228cc299703d5b09d0 (diff)
downloadbun-387f1260c9dc0cea667b44ec0152fff0cd4def25.tar.gz
bun-387f1260c9dc0cea667b44ec0152fff0cd4def25.tar.zst
bun-387f1260c9dc0cea667b44ec0152fff0cd4def25.zip
Get Next.js Pages Router to work (#6095)
* hell * make it so bun-debug-src * teag * wild * yippee * fas * fix async hooks assertions * yap * yeah that's wild * aa * a * increase time allowed * so trivial
Diffstat (limited to 'src/js/_codegen/client-js.ts')
-rw-r--r--src/js/_codegen/client-js.ts12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/js/_codegen/client-js.ts b/src/js/_codegen/client-js.ts
index 2db3305fa..bd9ed63f4 100644
--- a/src/js/_codegen/client-js.ts
+++ b/src/js/_codegen/client-js.ts
@@ -27,10 +27,18 @@ export function createAssertClientJS(publicName: string) {
return `
let $assert = function(check, sourceString, ...message) {
if (!check) {
- console.error('[${publicName}] ASSERTION FAILED: ' + sourceString);
- if(message.length)console.warn (' ${" ".repeat(publicName.length)}', ...message);
+ const prevPrepareStackTrace = Error.prepareStackTrace;
+ Error.prepareStackTrace = (e, stack) => {
+ return e.name + ': ' + e.message + '\\n' + stack.slice(1).map(x => ' at ' + x.toString()).join('\\n');
+ };
const e = new Error(sourceString);
+ e.stack; // materialize stack
e.name = 'AssertionError';
+ Error.prepareStackTrace = prevPrepareStackTrace;
+ console.error('[${publicName}] ASSERTION FAILED: ' + sourceString);
+ if (message.length) console.warn(...message);
+ console.warn(e.stack.split('\\n')[1] + '\\n');
+ if (Bun.env.ASSERT === 'CRASH') process.exit(0xAA);
throw e;
}
}