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

"Transport not open" after upgrade to v4 #3838

Closed
RonnieRocket147 opened this issue Mar 14, 2021 · 9 comments
Closed

"Transport not open" after upgrade to v4 #3838

RonnieRocket147 opened this issue Mar 14, 2021 · 9 comments
Labels
bug Something isn't working
Milestone

Comments

@RonnieRocket147
Copy link

Describe the bug
Yesterday I have upgraded an Angular application which uses socket.io-client to version 4.0.0. The server was also upgraded to 4.0.0. Today our logging recorded multiple "Transport not open" errors on the client side which were never observed before. The (minified) stack trace looks like this:

m.send at line 1:198353      {snip} .onClose()),this}send(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)}onOpen(){this.readyState="open",thi {snip}
c.flush
c.sendPacket
c.write
PVQj.t.Manager._packet
t.Socket.packet
t.Socket.emit

To Reproduce
Unable to reproduce so far.

Platform:

  • Device: Chrome 89 + Safari 14
  • OS: Windows + Mac

Additional context
socket.emit() is only called when socket.connected returns true. But somehow during the emit the Transport not open is thrown.

I have downgraded the client to 3.1.3 to see if the error persists and will update this issue tomorrow with the results.

@RonnieRocket147 RonnieRocket147 added the bug Something isn't working label Mar 14, 2021
@zxlin
Copy link

zxlin commented Mar 16, 2021

@RonnieRocket147 are you experiencing this on page reload?

I'm seeing this in our app too, repro is something like

window.addEventListener('unload', () => {
  socket.emit(...);
});

@RonnieRocket147
Copy link
Author

@zxlin no we experience it during normal usage. But it might well be related to the same commit you mentioned in socketio/engine.io-client#658.

Downgrading to 3.1.3 did resolve our issue.

@darrachequesne
Copy link
Member

I could indeed reproduce, thanks.

This seems to be linked to this commit, included in engine.io-client@4.1.2 and socket.io-client@3.1.2.

darrachequesne added a commit to socketio/engine.io-client that referenced this issue Mar 31, 2021
In some cases, a "Transport not open" error could be thrown when the
transport was silently closed in the onbeforeunload event (added in
[1]).

To reproduce:

```js
window.addEventListener("unload", () => {
  socket.write("...");
});
```

[1]: ed48b5d

Related: socketio/socket.io#3838
@darrachequesne
Copy link
Member

This should be fixed by socketio/engine.io-client@d291a4c, included in engine.io-client@5.0.1 and socket.io-client@4.0.1.

@darrachequesne darrachequesne added this to the 4.0.1 milestone Apr 1, 2021
@RonnieRocket147
Copy link
Author

Hi @darrachequesne

I noticed also the strange behaviour that socket.connected was true but the transport was silently closed internally which looks like a bug to me. Is this still the case and can the connected property be updated when the transport is silently closed in the onbeforeunload?

@darrachequesne
Copy link
Member

@RonnieRocket147 yes, that is still the case. Could you please explain what your use case is? And why you think it is a bug?

Note: this change was meant to fix the issue here: #3639

@RonnieRocket147
Copy link
Author

Let me try to explain my concern. The Transport not open error I noticed after upgrading the client to 4.0.0 was happening when users were performing actions in our web application. So they were not navigating away from the page. The introcuded fix just silences this error now so my fear is there is another issue which will go unnoticed now.

If socket.connected is true and the emit is silently dropped due to Transport not open how can this be detected?

Thank you!

@texonidas
Copy link

I'm having a similar issue to @RonnieRocket147, ours seems to be triggered by a user clicking on tel protocol links. The user in question also has relatively poor internet, but it only occurs as an actual error when tel protocol links are clicked.

@RonnieRocket147
Copy link
Author

This could perfectly explain why I noticed random "Transport not open" errors after users where clicking on the page.

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

4 participants