Skip to content

fix!: Improve error handling when environment fetch fails. Minor type safety breaking changes #339

fix!: Improve error handling when environment fetch fails. Minor type safety breaking changes

fix!: Improve error handling when environment fetch fails. Minor type safety breaking changes #339

Triggered via pull request March 20, 2025 17:13
Status Failure
Total duration 36s
Artifacts

pull_request.yaml

on: pull_request
Matrix: build-and-test
Fit to window
Zoom out
Zoom in

Annotations

20 errors
Unhandled error: tests/sdk/flagsmith.test.ts#L136
Error: API is unavailable ❯ tests/sdk/flagsmith.test.ts:136:33 ❯ node_modules/@vitest/runner/dist/index.js:629:21 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "default flag handler used when timeout occurs". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: tests/sdk/flagsmith-identity-flags.test.ts#L144
Error: API is unavailable ❯ tests/sdk/flagsmith-identity-flags.test.ts:144:27 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 ❯ withEnv node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:90:5 This error originated in "tests/sdk/flagsmith-identity-flags.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith-identity-flags.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 401 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:105:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:206:5 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test onEnvironmentChange is called after error". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 401 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:105:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:222:9 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test_localEvaluation_true__identity_overrides_evaluated". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L353
TypeError: Body is unusable: Body has already been read ❯ consumeBody node:internal/deps/undici/undici:5712:15 ❯ _Response.json node:internal/deps/undici/undici:5665:18 ❯ Flagsmith.getJSONResponse sdk/index.ts:353:21 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.getIdentityFlags sdk/index.ts:221:37 ❯ tests/sdk/flagsmith.test.ts:370:26 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
build-and-test (22.x)
Process completed with exit code 1.
build-and-test (20.x)
The job was canceled because "_22_x" failed.
Unhandled error: tests/sdk/flagsmith.test.ts#L136
Error: API is unavailable ❯ tests/sdk/flagsmith.test.ts:136:33 ❯ node_modules/@vitest/runner/dist/index.js:629:21 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "default flag handler used when timeout occurs". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: tests/sdk/flagsmith-identity-flags.test.ts#L144
Error: API is unavailable ❯ tests/sdk/flagsmith-identity-flags.test.ts:144:27 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 ❯ withEnv node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:90:5 This error originated in "tests/sdk/flagsmith-identity-flags.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith-identity-flags.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 401 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:206:5 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test onEnvironmentChange is called after error". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 401 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:222:9 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test_localEvaluation_true__identity_overrides_evaluated". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L353
TypeError: Body is unusable: Body has already been read ❯ consumeBody node:internal/deps/undici/undici:5712:15 ❯ _Response.json node:internal/deps/undici/undici:5665:18 ❯ Flagsmith.getJSONResponse sdk/index.ts:353:21 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.getIdentityFlags sdk/index.ts:221:37 ❯ tests/sdk/flagsmith.test.ts:370:26 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
build-and-test (20.x)
Process completed with exit code 1.
build-and-test (18.x)
The job was canceled because "_22_x" failed.
Unhandled error: tests/sdk/flagsmith-identity-flags.test.ts#L144
Error: API is unavailable ❯ tests/sdk/flagsmith-identity-flags.test.ts:144:27 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 ❯ withEnv node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:90:5 This error originated in "tests/sdk/flagsmith-identity-flags.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith-identity-flags.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: tests/sdk/flagsmith.test.ts#L136
Error: API is unavailable ❯ tests/sdk/flagsmith.test.ts:136:33 ❯ node_modules/@vitest/runner/dist/index.js:629:21 ❯ node_modules/@vitest/runner/dist/index.js:146:14 ❯ node_modules/@vitest/runner/dist/index.js:533:11 ❯ runWithTimeout node_modules/@vitest/runner/dist/index.js:39:7 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:17 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 ❯ startTests node_modules/@vitest/runner/dist/index.js:1271:3 ❯ node_modules/vitest/dist/chunks/runBaseTests.3qpJUEJM.js:126:11 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "default flag handler used when timeout occurs". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 401 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:206:5 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test onEnvironmentChange is called after error". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L348
Error: Invalid request made to Flagsmith API. Response status code: 403 ❯ Flagsmith.getJSONResponse sdk/index.ts:348:19 ❯ processTicksAndRejections node:internal/process/task_queues:95:5 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.updateEnvironment sdk/index.ts:306:33 ❯ tests/sdk/flagsmith.test.ts:222:9 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 ❯ runFiles node_modules/@vitest/runner/dist/index.js:1262:5 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "test_localEvaluation_true__identity_overrides_evaluated". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Unhandled error: sdk/index.ts#L353
TypeError: Body is unusable ❯ specConsumeBody node:internal/deps/undici/undici:5556:15 ❯ _Response.json node:internal/deps/undici/undici:5458:18 ❯ Flagsmith.getJSONResponse sdk/index.ts:353:21 ❯ Flagsmith.getEnvironmentFromApi sdk/index.ts:383:34 ❯ Flagsmith.fetchEnvironment sdk/index.ts:278:33 ❯ Flagsmith.getIdentityFlags sdk/index.ts:221:37 ❯ tests/sdk/flagsmith.test.ts:370:26 ❯ node_modules/@vitest/runner/dist/index.js:533:5 ❯ runTest node_modules/@vitest/runner/dist/index.js:1056:11 ❯ runSuite node_modules/@vitest/runner/dist/index.js:1205:15 This error originated in "tests/sdk/flagsmith.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/sdk/flagsmith.test.ts". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
build-and-test (18.x)
The operation was canceled.