Skip to content

Instantly share code, notes, and snippets.

@jkrems
Last active January 8, 2016 19:55
Show Gist options
  • Save jkrems/16deb968b7a66c34a3f2 to your computer and use it in GitHub Desktop.
Save jkrems/16deb968b7a66c34a3f2 to your computer and use it in GitHub Desktop.
CLS failure on iojs >= 1.8.4 (possibly earlier)
#!/usr/bin/env bash
./configure
make -j4
./iojs cls-failure.js
'use strict';
var http = require('http');
var assert = require('assert');
var cls = require('continuation-local-storage');
var ns = cls.createNamespace('minimal-cls-failure');
ns.run(function() {
ns.set('y', 63);
http.get('http://api.reddit.com/r/javascript/about.json', function(res) {
// ns.bindEmitter(res);
console.log('"response"');
assert.strictEqual(ns.get('y'), 63,
'Has the right context in "response" event');
res.on('data', function() {
console.log('"data"');
// This fails:
assert.strictEqual(ns.get('y'), 63,
'Has the right context in "data" event');
});
res.on('end', function() {
console.log('"end"');
// This fails:
assert.strictEqual(ns.get('y'), 63,
'Has the right context in "end" event');
console.log('ok');
});
});
});
@jkrems
Copy link
Author

jkrems commented Jul 27, 2015

Possibly related to emitOne change here: nodejs/node@b677b84

Started happening between 1.7.1 and 1.8.1:

> nvm use iojs-1.7.1 && node cls-failure.js; nvm use iojs-1.8.1 && node cls-failure.js
Now using io.js v1.7.1 (npm v2.7.6)
"response"
"data"
"end"
ok
Now using io.js v1.8.1 (npm v2.8.3)
"response"
"data"

assert.js:88
  throw new assert.AssertionError({
        ^
AssertionError: Has the right context in "data" event

Issue: othiym23/node-continuation-local-storage#44

@jkrems
Copy link
Author

jkrems commented Jul 27, 2015

Results from git bisect:

> git bisect log
# bad: [7b7da2edf79a95aa9ab2b7ff6dc74557d4cd0d64] 2015-04-20 io.js v1.8.1 Release
# good: [44e1f68fb66c01dfda736e4e938f241e1b2ef77d] 2015-04-14 io.js v1.7.1 Release
git bisect start 'v1.8.1' 'v1.7.1'
# good: [12e51d56c1007d83c4bc1c1450b5f45837c27164] doc: add Addon API WG
git bisect good 12e51d56c1007d83c4bc1c1450b5f45837c27164
# bad: [5b844e140b01bff010747e303c0d9e0f3a0f5514] module: fix style
git bisect bad 5b844e140b01bff010747e303c0d9e0f3a0f5514
# bad: [3ad82c335deff29a1db5a391f893dc6d2ff1e63a] module: handle NODE_PATH in require('.')
git bisect bad 3ad82c335deff29a1db5a391f893dc6d2ff1e63a
# bad: [76f219c128ea729972226c064e79f9b3aa494eff] doc: Document forced pushing with git
git bisect bad 76f219c128ea729972226c064e79f9b3aa494eff
# bad: [10e31ba56c676bdcad39ccad22ea9117733b8eb5] node: allow multiple arguments passed to nextTick
git bisect bad 10e31ba56c676bdcad39ccad22ea9117733b8eb5
# first bad commit: [10e31ba56c676bdcad39ccad22ea9117733b8eb5] node: allow multiple arguments passed to nextTick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment