Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traffic: [Status 101] - The status provided (101) is outside the range [200, 599] #54

Open
JeanDamien opened this issue Jul 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JeanDamien
Copy link

Description

If the user uses a .har file that contained a websocket entry , this package will throw an exception:

Uncaught (in promise) RangeError: Failed to construct 'Response': The status provided (101) is outside the range [200, 599].
    at toResponse (@mswjs_source_traffic.js)
    at fromTraffic (@mswjs_source_traffic.js)

https://github.com/mswjs/source/blob/main/src/traffic/utils/har-utils.ts#L40

Reproduction steps

  • Go to a site that open a websocket (your dev env might be enough if it has a fast-refresh)

  • Open your network and look for a WS resource (like ws://localhost:3006/ GET 101 Switching Protocols)
    image

  • Export the logs as HAR file

  • Try to generate the request handlers following the instructions

HAR file

test/traffic/fixtures/archives/entry-with-ws.har

Test template

  it(
    'does not throw an exception given an HAR file with a websocket entry',
    () => {
      const traffic = readArchive(
        'test/traffic/fixtures/archives/entry-with-ws.har',
      )
      expect(() => fromTraffic(traffic)).not.toThrow()
    },
  )

Expected behavior

It would be ideal if the library didn't throw an exception, or if we could add an entry in the documentation advising users to filter those entries in HAR before using it.

Workaround

fromTraffic(traffic, (entry) => {
  if (entry._resourceType === 'websocket') {
    return
  }
  return entry
})
@JeanDamien JeanDamien added the bug Something isn't working label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant