Skip to content

WebSocket error when native overlays appear over WebView during test execution #4874

@cunhabruno

Description

@cunhabruno

Did you test using the latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test fail and you're not sure why?

  • I have read the troubleshooting guide and it didn't help me.

What happened?

When running E2E tests that interact with WebView elements and then trigger native modals/drawers to open, Detox throws an unexpected WebSocket error that crashes the test.

What was the expected behaviour?

Expected Behavior
Detox should gracefully handle invokeResult messages that arrive after the test context has switched from WebView to native layer

Actual Behavior
The test crashes with a DetoxRuntimeError because the WebSocket message handler doesn't expect invokeResult messages when there's no corresponding inflight promise.

Help us reproduce this issue!

  1. Execute a WebView action (e.g., scroll, waitfor) that triggers asynchronous operations
  2. The action causes a native modal/drawer to open over the WebView
  3. WebView operations complete and send invokeResult messages back through WebSocket
  4. Detox has already switched context to native layer
  5. WebSocket handler rejects the invokeResult message as unexpected
  6. This might be difficult to reproduce, as there might be some specific async process happening in my web app

In what environment did this happen?

Detox version: 20.41.2
Platform: iOS
React Native version: 0.77.3
Has Fabric (React Native's new rendering system) enabled: yes
Node version: 22.13.1
Device model: Any Iphone
iOS version: 26.0
macOS version:
Xcode version: 26.1
Test-runner (select one): jest

Detox logs

Detox logs
Unexpected error on an attempt to handle the response received over the web socket.

Unexpected message received over the web socket: invokeResult

The payload was:
{"messageId":9,"type":"invokeResult","params":{}}

Device logs

Device logs
paste your device.log here!

More data, please!

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions