question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Does not work with node v6.5

See original GitHub issue

Hi, I have a webapp that I built using the koa v2 framework. I use koa-convert, koa-generic-session and koa-redis to store user sessions in my redis instance. Since upgrading to node v6.5, my webapp fails with the following stacktrace:

TypeError: Cannot read property 'done' of undefined
      at next (/Users/dev/work/node_modules/co/index.js:98:14)
      at onFulfilled (/Users/dev/work/node_modules/co/index.js:69:7)
      at /Users/Stephen/dev/work/node_modules/co/index.js:54:5
      at Object.co (/Users/dev/work/node_modules/co/index.js:50:10)
      at next (/Users/dev/work/node_modules/co/index.js:99:29)
      at onFulfilled (/Users/dev/work/node_modules/co/index.js:69:7)

It worked fine with node v6.4. The stacktrace doesnt go past co, but through trial and error, I deleted a lot of third party libs and middleware and narrowed it down to this block of code:

app.use(convert(session({
  key: 'session',
  errorHandler(err, type, ctx) {
    console.error(err, type)
  },
  store: redisStore({ url: config.redis.url })
})))

which can be reduced to app.use(convert(session())) and still trigger the same bug.

I do not use the convert lib anywhere else in the app so I cannot quickly test to see if the issue is specifically in the convert or session lib.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
targoscommented, Aug 31, 2016

This is a bug in V8 with tail call optimization. The --harmony-tailcalls flag (implied by --harmony) is enough to trigger it. It will probably not be fixed in Node.js because the feature is not considered stable in V8 5.1. I suggest you drop the --harmony flag and if you really need one of the features that it activates, enable it directly. Here is the list: https://github.com/nodejs/node/blob/v6.5.0/deps/v8/src/flag-definitions.h#L211-L216

3reactions
bishtawicommented, Aug 31, 2016

Did some more testing. Its due to the --harmony flag that I am including when running node.

Smallest failing test case:

const Koa = require('koa')
const convert = require('koa-convert')
const session = require('koa-generic-session')

const app = new Koa()
app.use(convert(session()))

app.listen(3000)

Running node --harmony index.js then hitting localhost:3000 in a webbrowser returns a 500 instead of the expected 404.

Running without the harmony flag works as expected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm does not support Node.js v12.18.3 - Stack Overflow
I found the work-around ! First you need to open your cmd line, and use " npm install -g npm@latest " you'll get...
Read more >
How to fix 'npm does not support Node.js v14' error on ...
Uninstall node.js (Windows Add/Remove programs) · Manually delete the npm folder from your user profile (%APPDATA%/roaming/npm) · Install node.js ...
Read more >
Support Node 6 installs | Better world by better software
In this blog post I will show how to bundle and transpile your NPM package so it truly runs on Node v8.0.0 or...
Read more >
npm does not support Node.js v10.15.2 · Issue #1877 - GitHub
It looks like current installed npm is not compatible with Node.js version you are using. You'll probably need to update your npm using...
Read more >
node-sass - npm
Install. npm install node-sass. Some users have reported issues installing on Ubuntu due to node being registered to another package.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found