firebase / firebase/firebase-tools

initializeTestEnvironment sometimes failed due to Node.js fetch failed by "SocketError: other side closed"

Open
#8,383 4 comments 1 reaction 0 assignees View on GitHub
emulator-suite type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 13.35.1
**firebase:** 11.5.0
**@firebase/rules-unit-testing:** 4.0.1

**Platform:**macOS

### [REQUIRED] Test case

Running multiple tests in CI using `initializeTestEnvironment`, eventually a random test fails with a `TypeError: fetch failed` error with a `Cause:` `SocketError: other side closed` in the `discoverEmulators` function from `@firebase/rules-unit-testing`:

```
TypeError: fetch failed
...
at discoverEmulators (node_modules/.pnpm/@firebase+rules-unit-testing@4.0.1_firebase@11.5.0/node_modules/@firebase/rules-unit-testing/src/impl/discovery.ts:31:15)
at initializeTestEnvironment (node_modules/.pnpm/@firebase+rules-unit-testing@4.0.1_firebase@11.5.0/node_modules/@firebase/rules-unit-testing/src/initialize.ts:66:32)
at

Cause:
SocketError: other side closed
```

### [REQUIRED] Steps to reproduce

Only one test is failing randomly over hundreds that we have, so reproducing is very difficult.
It also happens only in CI and not locally.

It looks like it's happening randomly for other users since starting using firebase@11 and an issue has already been opened on the `firebase-js-sdk` repo: https://github.com/firebase/firebase-js-sdk/issues/8690

They recommended opening an issue here since it looks related to the emulator rather than the SDK code.

### [REQUIRED] Expected behavior

Tests shouldn't fail, as they didn't before moving to firebase@11, although keeping the previously working firebase-tools@13.13.0 version or the newest firebase-tools@13.35.1 doesn't change anything.

### [REQUIRED] Actual behavior

_Described in the Test case_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.