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

WebSocket messages do not occur with a Zone #108

Open
matthewp opened this issue Feb 15, 2017 · 6 comments
Open

WebSocket messages do not occur with a Zone #108

matthewp opened this issue Feb 15, 2017 · 6 comments
Labels

Comments

@matthewp
Copy link
Contributor

ws.onmessage = function(){

};

If some behavior is completed within a websocket message this needs to be wrapped within the Zone.

@matthewp matthewp added the bug label Feb 15, 2017
@matthewp matthewp self-assigned this Feb 15, 2017
@frank-dspeed
Copy link
Contributor

is this the bug feathersjs-ecosystem/socketio#81

they say zones can't handle socket.io in general.

@matthewp
Copy link
Contributor Author

Yep, this is true.

@frank-dspeed
Copy link
Contributor

as far as i understand
For can-zone to work we have to override various task-creating functionality, this is the list of what we currently implement:

Macrotasks

setTimeout
XMLHttpRequest
Microtasks

requestAnimationFrame
Promise
process.nextTick

we need to implament socket.io here or i use a promis based socket io lib?

@matthewp
Copy link
Contributor Author

I think the socket.io issue is because they do a recursive setTimeout. Without some heuristic to detect this I'm not sure that's fixable.

@matthewp
Copy link
Contributor Author

Yes, using Zone.ignore will ignore any async tasks that are called within.

@frank-dspeed
Copy link
Contributor

frank-dspeed commented Jun 26, 2017

Current Workaround is

  1. rendering head and body stache directly to html and disable done-autorender
  • pro: it works without SSR
  • con: Don't works with SSR
  1. Use done-autorender without zones
  1. use ignore Prototype from can-zone
    The issue is Zone related. The reason it is not rendering is because the Zone never completes and done-autorender waits for the Zone to complete. You can use Zone.ignore to ignore functions:
var Zone = require("can-zone");
var someFunctionThatCallsSetInterval = require("dep");

var ignored = Zone.ignore(someFunctionThatCallsSetInterval);

// Now you can safely call ignored()
ignored()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants