refactor(javascript): MessageProcessor abstraction added#176
Open
Reversean wants to merge 1 commit intorefactor/breadcrumb-storefrom
Open
refactor(javascript): MessageProcessor abstraction added#176Reversean wants to merge 1 commit intorefactor/breadcrumb-storefrom
Reversean wants to merge 1 commit intorefactor/breadcrumb-storefrom
Conversation
3a8de71 to
3e46e20
Compare
neSpecc
reviewed
Apr 1, 2026
packages/javascript/src/messages/console-catcher-message-processor.ts
Outdated
Show resolved
Hide resolved
3e46e20 to
1704f75
Compare
9890ddb to
afc73fa
Compare
1704f75 to
eba517d
Compare
…ted in catcher event processing pipeline - MessageProcessor interface and MessageHint type - BrowserMessageProcessor, BreadcrumbsMessageProcessor, ConsoleCatcherMessageProcessor, DebugMessageProcessor - replaced inline addon logic with sequential MessageProcessor pipeline
neSpecc
reviewed
Apr 9, 2026
| * Snapshot of event context captured synchronously at error time, | ||
| * before any processing. | ||
| */ | ||
| export interface MessageHint { |
Member
There was a problem hiding this comment.
Term "hint" is not clear, let's find a better alternative
Comment on lines
+408
to
+409
| const hint = { error, | ||
| breadcrumbs: this.breadcrumbStore?.get() }; |
Member
There was a problem hiding this comment.
Suggested change
| const hint = { error, | |
| breadcrumbs: this.breadcrumbStore?.get() }; | |
| const hint = { | |
| error, | |
| breadcrumbs: this.breadcrumbStore?.get() | |
| }; |
|
|
||
| if (result === null) { | ||
| return; | ||
| } |
Member
There was a problem hiding this comment.
This behavior should be documented in MessageProcessor jsdoc and covered by test
| @@ -198,10 +208,15 @@ export default class Catcher { | |||
| if (settings.breadcrumbs !== false) { | |||
| this.breadcrumbStore = BrowserBreadcrumbStore.getInstance(); | |||
| this.breadcrumbStore.init(settings.breadcrumbs ?? {}); | |||
Member
There was a problem hiding this comment.
maybe we should init it inside the BreadcrumbsMessageProcessor constructor? Like in ConsoleOutputAddonMessageProcessor?
|
|
||
| this.sendErrorFormatted(errorFormatted); | ||
| } catch (e) { | ||
| if (e instanceof EventRejectedError) { |
Member
There was a problem hiding this comment.
if EventRejectedError is not used anymore, it should be deleted.
Check this:
#103
| /** | ||
| * Event was rejected by user using the beforeSend method | ||
| */ | ||
| const filtered = this.applyBeforeSendHook(payload); |
Member
There was a problem hiding this comment.
Suggested change
| const filtered = this.applyBeforeSendHook(payload); | |
| const payloadPostBeforeSend = this.applyBeforeSendHook(payload); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Part of the broader effort to extract environment-agnostic logic into
@hawk.so/core(#151). The blocker wasCatcher.formatAndSend()— addon collection (viewport, console output, raw error data) was hardcoded inline against browser APIs with no seam to override it for a different runtime.Why MessageProcessor?
Each
MessageProcessorencapsulates one piece of env-specific addon logic. The pipeline loop belongs in a futureBaseCatcher; processors are registered by the concrete catcher. A futureNodeCatcherregisters Node-appropriate processors without touching browser code.BreadcrumbStorefollows the same pattern — core owns the interface, the browser implementation lives in the browser package.Why ProcessingPayload?
Extracting processors exposed a latent ordering dependency:
ConsoleOutputAddonMessageProcessorandDebugAddonMessageProcessorguarded onpayload.addonsexisting, which onlyBrowserAddonMessageProcessorcreated.ProcessingPayload<T>keepsaddonsalways initialized but structurally partial during the pipeline — each processor writes its fields freely, and the fullJavaScriptAddonscontract is enforced only at the send boundary.Changes
MessageProcessorinterface,ProcessingPayload<T>type,MessageHint,BreadcrumbStoreabstraction,BreadcrumbsMessageProcessorBrowserAddonMessageProcessor,ConsoleOutputAddonMessageProcessor,DebugAddonMessageProcessor— each encapsulates formerly inline addon logicMessageProcessorpipeline