Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix excessive framework noise in error stack traces#2442

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
omkardongre wants to merge1 commit intotriggerdotdev:main
base:main
Choose a base branch
Loading
fromomkardongre:fix/slack-alert-stack-trace-noise

Conversation

@omkardongre
Copy link

Problem

Users reported excessive framework noise in Slack error alerts, making debugging difficult. Issue#2097 shows stack traces cluttered with trigger.dev internals like:

  • _RunTimelineMetricsAPI.measureMetric
  • ConsoleInterceptor.intercept
  • taskExecutor.ts internal calls

Solution

Applied existing correctErrorStackTrace filtering toBUILT_IN_ERROR case in createJsonErrorObject - it was the only error type returning raw stack traces without filtering.

Changes:

  • WrapenhancedError.stackTrace with correctErrorStackTrace() for filtering stack traces
  • AddAsyncLocalStorage pattern toLINES_TO_IGNORE to remove OpenTelemetry noise

Impact

Cleaner error experiences across all user-facing error contexts usingcreateJsonErrorObject:

  • Slack alerts (primary issue resolved)
  • Email notifications
  • API responses
  • Run streams

Closes#2097


✅ Checklist

  • ✅ I have followed every step in thecontributing guide
  • ✅ The PR title follows the convention.
  • ✅ I ran and tested the code works

Testing

  • Manual: Verified Slack alerts now show clean stack traces with only user code
  • Unit: Added test for framework noise filtering in stack traces

Changelog

Improve user-facing error readability by filtering framework noise from stack traces


Screenshots

N/A

@changeset-bot
Copy link

changeset-botbot commentedAug 27, 2025
edited
Loading

🦋 Changeset detected

Latest commit:e16f893

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
NameType
@trigger.dev/corePatch
@trigger.dev/buildPatch
trigger.devPatch
@trigger.dev/pythonPatch
@trigger.dev/redis-workerPatch
@trigger.dev/schema-to-jsonPatch
@trigger.dev/sdkPatch
@internal/cachePatch
@internal/clickhousePatch
@internal/redisPatch
@internal/replicationPatch
@internal/run-enginePatch
@internal/schedule-enginePatch
@internal/testcontainersPatch
@internal/tracingPatch
@internal/zod-workerPatch
d3-chatPatch
references-d3-openai-agentsPatch
references-nextjs-realtimePatch
@trigger.dev/react-hooksPatch
@trigger.dev/rscPatch
@trigger.dev/databasePatch
@trigger.dev/otlp-importerPatch

Not sure what this means?Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitaibot commentedAug 27, 2025
edited
Loading

Walkthrough

Reworks stack-trace handling in packages/core/src/v3/errors.ts: BUILT_IN_ERROR now generates its stackTrace via correctErrorStackTrace(enhancedError.stackTrace, undefined, { removeFirstLine: false }) so the first line is preserved while per-line normalization and frame filtering run; AsyncLocalStorage frames are added to the ignore list. Adds a unit test at packages/core/test/errors.test.ts that asserts user frames are preserved and internal/framework frames (including AsyncLocalStorage and internal modules) are filtered from createJsonErrorObject output. Adds a changeset bumping @trigger.dev/core with a note about improved stack-trace readability. No public API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat withCodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag@coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag@coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on oursupport page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type@coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add@coderabbitai ignore or@coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add@coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add@coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a.coderabbit.yaml file to the root of your repository.
  • Please see theconfiguration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit ourStatus Page to check the current availability of CodeRabbit.
  • Visit ourDocumentation for detailed information on how to use CodeRabbit.
  • Join ourDiscord Community to get help, request features, and share feedback.
  • Follow us onX/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/core/src/v3/errors.ts (1)

378-379:Broaden (or tighten) AsyncLocalStorage filtering to reduce false positives and cover more runtimes

/AsyncLocalStorage/ may hide legitimate user frames and might miss other node internals. Consider adding targeted patterns for node built-ins and OTEL context manager while keeping current behavior.

Apply:

 const LINES_TO_IGNORE = [   /ConsoleInterceptor/,   /TriggerTracer/,   /TaskExecutor/,   /EXECUTE_TASK_RUN/,   /@trigger.dev\/core/,   /packages\/core\/src\/v3/,   /safeJsonProcess/,   /__entryPoint.ts/,   /ZodIpc/,   /startActiveSpan/,   /processTicksAndRejections/,-  /AsyncLocalStorage/,+  /AsyncLocalStorage/,                     // keep for backward compatibility+  /AsyncLocalStorageContextManager/,       // otel context mgr+  /node:async_hooks/,                      // node built-in scheme+  /node:internal\//,                       // other node internals+  /@opentelemetry\//,                      // otel frames ];
packages/core/test/errors.test.ts (1)

25-47:Also assert header removal and preserved name/message

Since removeFirstLine is now applied, assert the stack no longer contains the header, and that name/message are still surfaced.

Apply:

     const jsonError = createJsonErrorObject(taskRunError);+    // Header should be removed from stackTrace but preserved in fields+    expect(jsonError.stackTrace).not.toContain("Error: Network error occurred");+    expect(jsonError.name).toBe("Error");+    expect(jsonError.message).toBe("Network error occurred");
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between96243ef andcf9be9f.

📒 Files selected for processing (3)
  • .changeset/dry-taxis-wash.md (1 hunks)
  • packages/core/src/v3/errors.ts (2 hunks)
  • packages/core/test/errors.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • packages/core/test/errors.test.ts
  • packages/core/src/v3/errors.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Our tests are all vitest

Files:

  • packages/core/test/errors.test.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

We use zod a lot in packages/core and in the webapp

Files:

  • packages/core/test/errors.test.ts
  • packages/core/src/v3/errors.ts
🧬 Code graph analysis (1)
packages/core/test/errors.test.ts (1)
packages/core/src/v3/errors.ts (1)
  • createJsonErrorObject (222-251)
🔇 Additional comments (3)
.changeset/dry-taxis-wash.md (1)

1-6:Patch bump and message look good

Clear, scoped changeset; patch level is appropriate for behavior-only change.

packages/core/src/v3/errors.ts (1)

230-233:Apply stack filtering for BUILT_IN_ERROR — good fix

Routing BUILT_IN_ERROR through correctErrorStackTrace with removeFirstLine improves user-facing stacks and aligns with other paths.

packages/core/test/errors.test.ts (1)

1-48:Strong, targeted test — preserves user frames and filters framework noise

Covers the key regression. Nice.

Comment on lines 230 to 233
stackTrace:correctErrorStackTrace(enhancedError.stackTrace,undefined,{
removeFirstLine:true,
}),
};
Copy link
Contributor

@coderabbitaicoderabbitaibotAug 27, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

💡 Verification agent

🧩 Analysis chain

Verify no consumers rely on the “Error: …” header being present in stackTrace

Since removeFirstLine drops the header line from stackTrace, double-check downstream formatters (Slack/email/API clients) don’t expect it there.

Run:


🏁 Script executed:

#!/bin/bash# Find usages that might format jsonError.stackTrace directlyrg -nP --type=ts --type=tsx -C2'\bcreateJsonErrorObject\s*\('rg -nP --type=ts --type=tsx -C2'\bstackTrace\b' apps packages

Length of output: 185


🏁 Script executed:

#!/bin/bash# Rerun search for createJsonErrorObject across TS and TSX files in apps and packagesrg -n'createJsonErrorObject\(' -C2 -g'*.{ts,tsx}' apps packages# Rerun search for direct stackTrace property access in apps and packagesrg -n'\.stackTrace\b' -C2 -g'*.{ts,tsx}' apps packages

Length of output: 12404


Adjust downstream consumers for new stackTrace format

We’ve confirmed that several formatting routines rely on the first line ofstackTrace being the"Error: …" header. Since we now strip that line by default, these consumers need to be updated to use the separatename/message fields rather than parsingstackTrace directly:

• packages/cli-v3/src/mcp/formatters.ts (around line 51)
Current:

if(run.error.stackTrace){lines.push(`Stack:${run.error.stackTrace.split("\n")[0]}`);}

Suggested:

- lines.push(`Stack: ${run.error.stackTrace.split("\n")[0]}`);+ // Use the explicit name/message fields now that header’s removed+ lines.push(`Stack: ${run.error.name || "Error"}: ${run.error.message}`);

• packages/cli-v3/src/dev/devOutput.ts (around line 260)
Current:

return`\n\n${error.stackTrace.replace(/^Error:/,chalkError("X Error: "))}\n`;

Suggested:

- ${error.stackTrace.replace(/^Error: /, chalkError("X Error: "))}+ ${chalkError("X Error: ")}${error.message}\n${error.stackTrace}

• apps/webapp/app/v3/services/alerts/deliverAlert.server.ts (line 705)
Current wrapserror.stackTrace ?? error.message in a code block. To preserve context, consider renderingError: ${error.name}: ${error.message} separately and then the trace.

• apps/webapp/app/routes//route.tsx (around line 911)
UI rendersenhancedError.stackTrace without the header—verify that the header is shown elsewhere (e.g. viaerror.name +error.message).

Please update these formatters/UI components to reference the dedicated error fields instead of assuming the header lives instackTrace.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@omkardongre Can you update this change to setremoveFirstLine: false that way we don't break these expectations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag@coderabbitai in a new comment, and I'll come hopping out!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@ericallam Thanks for the feedback. Updated removeFirstLine to false as it is better to keep the error header for compatibility and readability.

Add AsyncLocalStorage to LINES_TO_IGNORE (removes OpenTelemetry noise)Apply error stack trace filtering for createJsonErrorObjectAdd test for framework stack trace filteringAdd changesetThis change improves readability of error traces in user-facing contexts(Slack alerts, email notifications, API responses, run streams) byfiltering out internal framework noise that clutters error messages.
@omkardongreomkardongreforce-pushed thefix/slack-alert-stack-trace-noise branch fromcf9be9f toe16f893CompareSeptember 4, 2025 17:58
Copy link
Contributor

@coderabbitaicoderabbitaibot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/core/src/v3/errors.ts (1)

405-406:Narrow AsyncLocalStorage filter to avoid hiding legitimate user frames

The regex /AsyncLocalStorage/ is broad and may drop user stacks that use Node’s AsyncLocalStorage directly. Target OTEL/core frames instead.

Apply:

 const LINES_TO_IGNORE = [   /ConsoleInterceptor/,   /TriggerTracer/,   /TaskExecutor/,   /EXECUTE_TASK_RUN/,   /@trigger.dev\/core/,   /packages\/core\/src\/v3/,   /safeJsonProcess/,   /__entryPoint.ts/,   /ZodIpc/,   /startActiveSpan/,   /processTicksAndRejections/,-  /AsyncLocalStorage/,+  /\bAsyncLocalStorageContextManager\b/,+  /node:async_hooks/,+  /\bAsyncLocalStorage\.run\b/, ];
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and betweencf9be9f ande16f893.

📒 Files selected for processing (3)
  • .changeset/dry-taxis-wash.md (1 hunks)
  • packages/core/src/v3/errors.ts (2 hunks)
  • packages/core/test/errors.test.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/dry-taxis-wash.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/test/errors.test.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • packages/core/src/v3/errors.ts
{packages/core,apps/webapp}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

We use zod a lot in packages/core and in the webapp

Files:

  • packages/core/src/v3/errors.ts
🔇 Additional comments (2)
packages/core/src/v3/errors.ts (2)

230-233:BUILT_IN_ERROR stack filtering with header preserved — LGTM

Using correctErrorStackTrace with removeFirstLine: false keeps consumer expectations intact while filtering framework noise.


308-312:Confirm TASK_HAS_N0_EXECUTION_SNAPSHOT vs TASK_HAS_NO_EXECUTION_SNAPSHOT
Both the Zod schema inpackages/core/src/v3/schemas/common.ts (L181) and the branch inpackages/core/src/v3/errors.ts (L310) reference"TASK_HAS_N0_EXECUTION_SNAPSHOT" (zero). No occurrences of"TASK_HAS_NO_EXECUTION_SNAPSHOT" found; verify the intended code value against the spec and correct both locations if it should use the letter O.

Comment on lines +26 to +47
expect(jsonError.stackTrace).toContain(
"at fetchData (file:///src/trigger/utils/helper.ts:4:9)"
);
expect(jsonError.stackTrace).toContain(
"at processResponse (file:///src/trigger/utils/helper.ts:9:10)"
);
expect(jsonError.stackTrace).toContain(
"at parseResult (file:///src/trigger/utils/helper.ts:14:10)"
);
expect(jsonError.stackTrace).toContain("at callAPI (file:///src/trigger/services/api.ts:6:10)");
expect(jsonError.stackTrace).toContain("at localHelper (file:///src/trigger/example.ts:7:10)");
expect(jsonError.stackTrace).toContain("at run (file:///src/trigger/example.ts:17:12)");

// Should filter framework noise
expect(jsonError.stackTrace).not.toContain("_tracer.startActiveSpan.attributes");
expect(jsonError.stackTrace).not.toContain("taskExecutor.ts");
expect(jsonError.stackTrace).not.toContain("tracer.ts");
expect(jsonError.stackTrace).not.toContain("AsyncLocalStorage.run");
expect(jsonError.stackTrace).not.toContain("AsyncLocalStorageContextManager");
expect(jsonError.stackTrace).not.toContain("node_modules/@trigger.dev/core");
expect(jsonError.stackTrace).not.toContain(".npm/_npx");
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would prefer an inline snapshot here to be able just plainly see how the cleaned up stack trace looks like

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ericallamericallamericallam left review comments

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

+1 more reviewer

@capajcapajcapaj left review comments

Reviewers whose approvals may not affect merge requirements

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

bug: Slack alert sends more context that is needed

3 participants

@omkardongre@ericallam@capaj

[8]ページ先頭

©2009-2025 Movatter.jp