Skip to content

fix(webgl): invoke callback when the upload guard skips a report - #205

Open
bobbyg603 wants to merge 1 commit into
mainfrom
fix/webgl-reporter-skip-callback
Open

fix(webgl): invoke callback when the upload guard skips a report#205
bobbyg603 wants to merge 1 commit into
mainfrom
fix/webgl-reporter-skip-callback

Conversation

@bobbyg603

Copy link
Copy Markdown
Member

Closes #165

Problem

WebGLReporter did a bare yield break on both of its guard-skip paths, so the caller's Action<ExceptionReporterPostResult> was never invoked. DotNetStandardExceptionReporter invokes it with a skip result (Uploaded = false plus a "skipped" message), so the two reporters advertised the same IExceptionReporter contract while honouring different ones. Anything awaiting the callback to learn a report's fate hung forever on WebGL.

Fix

Both early returns in WebGLReporter now invoke the callback with the same ExceptionReporterPostResult shape and message wording DotNetStandardExceptionReporter uses:

  • LogMessageReceived -> "BugSplat upload skipped due to ShouldPostLogMessage check.", Exception = stackTrace
  • Post(Exception) -> "BugSplat upload skipped due to ShouldPostException check.", Exception = ex.ToString()

Post hoists ex.ToString() into a local so the skip result carries the same stack trace the upload path would have sent, matching the DotNet reporter line for line.

Audited every exit in the WebGL report flow: those two yield breaks were the only callback-less ones. WebGLReporter.Post(string, ...) has no early return, and WebGLExceptionClient.PostException already invokes the callback on both its success and failure paths.

Tests

Added to Tests/Runtime/Reporter/WebGLReporterTests.cs, alongside the existing guard-returns-false tests, using the existing FakeFalseReportUploadGuardService / FakeWebGLExceptionClient fakes:

  • LogMessageReceived_WhenReportUploadGuardServiceReturnsFalse_ShouldInvokeCallbackWithSkippedResult
  • Post_WhenReportUploadGuardServiceReturnsFalse_ShouldInvokeCallbackWithSkippedResult

Each asserts the callback fires and that Uploaded, Exception, and Message match the DotNet reporter's skip result.

Verification

Runtime/** + Tests/Runtime/** compile clean against the Unity 6000.5.6f1 managed assemblies, both with no platform define and with UNITY_WEBGL defined — WebGLReporter and WebGLClientSettingsRepository are compiled on all platforms, so the change had to build everywhere. 0 errors in both configurations; the only warnings are the two pre-existing CS0649s in Runtime/BugSplat.cs.

Both changed paths were also executed directly (a throwaway driver compiled into the same assembly, driving the coroutines to completion with a false guard): each invokes its callback exactly once with Uploaded = false, the expected message, the expected stack trace, and zero calls through to the exception client. Unity [UnityTest] cases were not run in the editor here; the test runner needs a licensed Unity session.

🤖 Generated with Claude Code

WebGLReporter bare `yield break`d on both guard-skip paths, so callers
that await the callback to learn a report's fate hang forever on WebGL.
DotNetStandardExceptionReporter already invokes the callback with a
skip result, so the two reporters advertised the same IExceptionReporter
contract while honouring different ones.

Both early returns now invoke the callback with the same
ExceptionReporterPostResult shape and message wording the DotNet
reporter uses. Post hoists ex.ToString() so the skip result carries the
same stack trace the upload path would have sent.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 11, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns WebGLReporter with the IExceptionReporter contract by ensuring the caller-provided callback is invoked even when the report upload guard prevents posting, matching the skip-result shape and wording used by DotNetStandardExceptionReporter.

Changes:

  • Invoke the callback with a “skipped” ExceptionReporterPostResult on WebGLReporter guard-skip paths (LogMessageReceived and Post(Exception)).
  • Hoist the exception string generation in WebGLReporter.Post(Exception) so the skip path returns the same exception/stack trace representation as the upload path.
  • Add Unity tests asserting the callback fires and that Uploaded/Exception/Message match the expected skip result.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Runtime/Reporter/WebGLReporter.cs Ensures callbacks are invoked on guard-skip paths with standardized “skipped” results.
Tests/Runtime/Reporter/WebGLReporterTests.cs Adds tests validating callback invocation and skipped-result contents for guard skips.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 60 to 64
public IEnumerator Post(Exception ex, IReportPostOptions options = null, Action<ExceptionReporterPostResult> callback = null)
{
var stackTrace = ex.ToString();

if (!reportUploadGuardService.ShouldPostException(ex))
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.

B9: WebGL reporter skips without invoking the callback

3 participants