Skip to content

Firefox & Vitest Browser Mode Timing Problems (CI) #2726

Description

@muelbr

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 20 or higher

Browsers

Firefox

Reproduction repository

https://github.com/muelbr/mswjs-bug

Reproduction steps

I recently reported a bug here: #2709
Currently it seems that only Firefox has some restrictions that can lead to timing problems when run in a CI environment with perhaps not the same CPU power as locally.

Reproduction Repo
Contains: Vue / Vitest Browser Mode / msw / testing-library

  • __tests__/index -> Test fixture
  • mws.test.ts / mws2.test.ts -> Tests for simple REST calls
  • vitest.config -> browser mode config

Test
npm run test:bug -> Test with firefox and maxWorkers: 1 (simulation slow environment)
Some errors start to appear:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

npm run test:all -> Test with all major browsers locally
Everything is fine.

Remark
Just a single test file works, but as soon as there is another test file, the errors are occurring.
Seems that the timing sequence between whole tests is critical with firefox, which is perhaps more restrictive or slow to start the service worker.

Kind regards

Current behavior

2 Test files using Firefox in a slow environment are causing some JSON.parse bugs

Expected behavior

Tests are all successful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds:triageIssues that have not been investigated yet.scope:browserRelated to MSW running in a browser

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions