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

add test demonstrating #595 in firefox #596

Merged
merged 5 commits into from
Mar 9, 2018

Conversation

devoidfury
Copy link
Contributor

@devoidfury devoidfury commented Mar 6, 2018

this fails for me about half the time in browser: Firefox 58.0.2 (64-bit)

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other
    Test

Current behaviour

connection :: should work in a worker

Error: expected 'пойдÑ\u0083 Ñ\u0081аÑ\u0082Ñ\u008c вÑ\u0081ем Ð' to equal 'пойду сать всем мпокойной ночи' (http://localhost:8080/__zuul/test-bundle.js:413)

    at process.on/global.onerror (__zuul/framework.js:6458:10)

Other information (e.g. related issues)

Issue #595

@darrachequesne
Copy link
Member

Thanks, I could indeed reproduce the issue.

I think this is linked to #592 (and socketio/engine.io-parser#81, eventually).

Due to a bug in the XHR implementation of the Firefox Worker, the line here throws:

if (xhr.readyState === 2) {
  try {
    var contentType = xhr.getResponseHeader('Content-Type');
    if (contentType !== 'application/octet-stream') {
      xhr.responseType = 'text';
    }
  } catch (e) {}
}

So the content is decoded as a buffer, which breaks UTF-8 encoding.

@devoidfury
Copy link
Contributor Author

I added a test for binary data in a worker, as well as adding a fix. Now instead of eagerly switching the responeType to 'arrayBuffer', delay doing that until checking the response headers. This seems to fix the issue and still works with binary data.

@darrachequesne darrachequesne merged commit 4349b64 into socketio:master Mar 9, 2018
@darrachequesne
Copy link
Member

Thanks!

@darrachequesne darrachequesne added this to the 3.2.1 milestone Mar 9, 2018
darrachequesne pushed a commit that referenced this pull request Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants