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

Stack overflow in IE 11 when publish called on channel with many pending unsubscribes #172

Open
audreyality opened this issue Apr 6, 2017 · 0 comments

Comments

@audreyality
Copy link

audreyality commented Apr 6, 2017

Steps to reproduce:

  1. Download postal-overflow.zip
  2. Unpack into a directory
  3. Load in IE 11
  4. Accept remote ActiveX (The warning comes up because it's loading JavaScript from disk)
  5. Click "Go" button

The text "Out of stack space" should appear next to the "Error: " label.

Minimal example:

var testChannel = postal.channel("test_channel");

for(var i = 0; i < 745; i++) {
    var sub = testChannel.subscribe("whatevs", function(){ this.unsubscribe(); });
    sub.context(sub);
}

testChannel.publish("whatevs");

It looks like stack space is exhausted due to recursion among postal.unsubscribe, postal.publish, and clearUnSubQueue. postal.unsubscribe publishes the system removed message on line 655. postal.publish invokes clearUnSubQueue on line 550 because the system-level publish is concluding. clearUnSubQueue calls postal.unsubscribe on line 392 because there are unsubscriptions remaining in unSubQueue.

It appears that I could end the recursion by setting _config.enableSystemMessages to false. Nothing within posal.js subscribes to these messages, and I'm not using any plugins at this time. Is this an appropriate workaround?

My local tests (IE 11 on Windows 10) started exhibiting the error after 745 unsubscriptions are added to the queue.

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

No branches or pull requests

1 participant