Open
Description
Operating System
Ubuntu 22.04
Environment (if applicable)
GitHub Actions
Firebase SDK Version
11.1.0
Firebase SDK Product(s)
Firestore
Project Tooling
React Native (Expo), Jest, TypeScript.
Detailed Problem Description
Hi Firebase team,
We recently occasionally have this error in our GitHub workflow, we've never had this issue in local device:
TypeError: fetch failed
4 |
5 | export async function initializeTestEnv() {
> 6 | const testEnv = await initializeTestEnvironment({
| ^
7 | projectId: "xxx",
8 | firestore: {
9 | rules: fs.readFileSync("firestore.rules", "utf8"),
at async discoverEmulators (node_modules/@firebase/rules-unit-testing/src/impl/discovery.ts:31:15)
at async initializeTestEnvironment (node_modules/@firebase/rules-unit-testing/src/initialize.ts:66:32)
at async initializeTestEnv (lib/utils/unit-test.ts:6:19)
at async Object.<anonymous> (lib/api-client/__tests__/user-report-test.node.ts:16:15)
Cause:
SocketError: other side closed
It seems await fetchImpl(makeUrl(hub, '/emulators'));
in discoverEmulators
throwed the SocketError: other side closed
and the codes didn't catch it then the codes crashed, can we retry when discoverEmulators
catches such an error?
Our Github workflow is similar to below:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.15"
- name: Install dependencies
run: |
npm install -g firebase-tools
yarn
- name: Lint
run: yarn eslint .
- name: Check TypeScript errors
run: yarn tsc --noEmit
- name: Run tests
run: firebase emulators:exec --only "firestore,auth,storage" "jest --runInBand --updateSnapshot --detectOpenHandles --forceExit --coverage"
We invoke initializeTestEnv
like below:
await initializeTestEnvironment({
projectId: "xxx",
firestore: {
rules: fs.readFileSync("firestore.rules", "utf8"),
host: 'localhost',
port: 8080,
},
storage: {
rules: fs.readFileSync("storage.rules", "utf8"),
host: 'localhost',
port: 9199,
},
hub: {
host: 'localhost',
port: 4400
}
})
We invoke it in each Jest unit test file in beforeAll
, there are 5 Jest test files in our codebase, so this function is called 5 consecutive times.
Steps and code to reproduce issue
N/A, this is an occasional issue and only observed in GitHub Actions workflows.