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

Comments

Projects
None yet
2 participants
@matthewp
Copy link
Contributor

matthewp commented Feb 15, 2017

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

This comment has been minimized.

Copy link
Contributor

frank-dspeed commented Jun 24, 2017

is this the bug feathersjs/socketio#81

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

@matthewp

This comment has been minimized.

Copy link
Contributor

matthewp commented Jun 24, 2017

Yep, this is true.

@frank-dspeed

This comment has been minimized.

Copy link
Contributor

frank-dspeed commented Jun 24, 2017

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

This comment has been minimized.

Copy link
Contributor

matthewp commented Jun 24, 2017

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

This comment has been minimized.

Copy link
Contributor

matthewp commented Jun 26, 2017

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

@frank-dspeed

This comment has been minimized.

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