Skip to content

ref(dev): Remove stacktrace limit on node errors in yarn scripts #5650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Aug 30, 2022

By default, Node errors only include the top 10 stackframes. Given the number of frames taken up by internal node code (especially when async functions are involved), this very often means that frames which might actually tell us something are cut off.

This solves that problem by removing the 10-frame limit for all errors thrown by node processes run through yarn. Note that this is a change which only affects our dev environment, not the SDK itself.

@AbhiPrasad
Copy link
Member

Took a look at this, no idea why remix is erroring. Maybe @onurtemizkan may know? Maybe we can fix the remix test issues by lowering --stack-trace-limit to 5000

@onurtemizkan
Copy link
Collaborator

onurtemizkan commented Sep 1, 2022

Looks like we were using the whole error with its stack trace as the event message on Remix server instrumentation. With this update, it created huge messages in breadcrumbs, which I think broke the Jest matchers.

Also, due to the huge event messages, the expected orders of transactions / events have changed. So I had to filter / separate them to make sure they don't flake.

So this diff below fixed the tests on my local.

Diff
diff --git a/.yarnrc b/.yarnrc
index 19daacaa0..3b1ccde9c 100644
--- a/.yarnrc
+++ b/.yarnrc
@@ -1 +1,3 @@
 workspaces-experimental true
+env:
+  NODE_OPTIONS --stack-trace-limit=100001
diff --git a/packages/remix/src/utils/instrumentServer.ts b/packages/remix/src/utils/instrumentServer.ts
index 04107fe07..7fffdad6e 100644
--- a/packages/remix/src/utils/instrumentServer.ts
+++ b/packages/remix/src/utils/instrumentServer.ts
@@ -68,7 +68,7 @@ function captureRemixServerException(err: Error, name: string): void {
     return;
   }
 
-  captureException(isResponse(err) ? extractData(err) : err, scope => {
+  captureException(isResponse(err) ? extractData(err) : err.message, scope => {
     scope.addEventProcessor(event => {
       addExceptionMechanism(event, {
         type: 'instrument',
diff --git a/packages/remix/test/integration/test/server/action.test.ts b/packages/remix/test/integration/test/server/action.test.ts
index b5a0dc082..65dc04220 100644
--- a/packages/remix/test/integration/test/server/action.test.ts
+++ b/packages/remix/test/integration/test/server/action.test.ts
@@ -37,13 +37,16 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
     const env = await RemixTestEnv.init(adapter);
     const url = `${env.url}/action-json-response/-1`;
 
-    const [transaction, event] = await env.getMultipleEnvelopeRequest({
+    const envelopes = await env.getMultipleEnvelopeRequest({
       url,
       count: 2,
       method: 'post',
       envelopeType: ['transaction', 'event'],
     });
 
+    const [transaction] = envelopes.filter(envelope => envelope[1].type === 'transaction');
+    const [event] = envelopes.filter(envelope => envelope[1].type === 'event');
+
     assertSentryTransaction(transaction[2], {
       contexts: {
         trace: {
@@ -79,13 +82,16 @@ describe.each(['builtin', 'express'])('Remix API Actions with adapter = %s', ada
     const env = await RemixTestEnv.init(adapter);
     const url = `${env.url}/action-json-response/-2`;
 
-    const [transaction_1, event, transaction_2] = await env.getMultipleEnvelopeRequest({
+    const envelopes = await env.getMultipleEnvelopeRequest({
       url,
       count: 3,
       method: 'post',
       envelopeType: ['transaction', 'event'],
     });
 
+    const [transaction_1, transaction_2] = envelopes.filter(envelope => envelope[1].type === 'transaction');
+    const [event] = envelopes.filter(envelope => envelope[1].type === 'event');
+
     assertSentryTransaction(transaction_1[2], {
       contexts: {
         trace: {
diff --git a/packages/remix/test/integration/test/server/loader.test.ts b/packages/remix/test/integration/test/server/loader.test.ts
index 8d8b0b93c..fa6d88658 100644
--- a/packages/remix/test/integration/test/server/loader.test.ts
+++ b/packages/remix/test/integration/test/server/loader.test.ts
@@ -77,12 +77,15 @@ describe.each(['builtin', 'express'])('Remix API Loaders with adapter = %s', ada
     const env = await RemixTestEnv.init(adapter);
     const url = `${env.url}/loader-json-response/-1`;
 
-    const [transaction_1, event, transaction_2] = await env.getMultipleEnvelopeRequest({
+    const envelopes = await env.getMultipleEnvelopeRequest({
       url,
       count: 3,
       envelopeType: ['transaction', 'event'],
     });
 
+    const [transaction_1, transaction_2] = envelopes.filter(envelope => envelope[1].type === 'transaction');
+    const [event] = envelopes.filter(envelope => envelope[1].type === 'event');
+
     assertSentryTransaction(transaction_1[2], {
       contexts: {
         trace: {

Can open a PR if that makes sense?

@lobsterkatie
Copy link
Member Author

Thanks for looking into this, @onurtemizkan! I'll leave some comments on #5711.

lobsterkatie pushed a commit that referenced this pull request Sep 12, 2022
…5711)

Related: #5650

Limited maximum stacktrace length for Remix server-side integration tests.

Also updated tests to filter by type and separate consecutive multi-type envelopes, and not to trust the capturing order.
@lobsterkatie lobsterkatie force-pushed the kmclb-full-stacktraces-in-dev branch from 78c3775 to 005d2d0 Compare September 12, 2022 05:51
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.46 KB (+0.02% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 60.11 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.04 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 53.03 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 19.83 KB (0%)
@sentry/browser - Webpack (minified) 64.42 KB (0%)
@sentry/react - Webpack (gzipped + minified) 19.85 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 44.84 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.97 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.35 KB (+0.01% 🔺)

@lobsterkatie lobsterkatie merged commit f9244f3 into master Sep 12, 2022
@lobsterkatie lobsterkatie deleted the kmclb-full-stacktraces-in-dev branch September 12, 2022 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants