koajs / examples

Example Koa apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Internal Server Error for stream-server-side-events example

richb-hanover opened this issue · comments

Using master from koajs/examples with node v0.12.0 to run the stream-server-side-events example program, I had a couple problems:

  1. I had to add if (!module.parent) app.listen(3000); as the final line of app.js

  2. I got the following error when I connected to http://localhost:3000

    richs-mbp-10715:stream-server-side-events richb$ node --harmony app.js
    
    RangeError: msecs must be a non-negative finite number
        at Object.exports.enroll (timers.js:160:11)
        at Socket.setTimeout (net.js:329:12)
        at IncomingMessage.setTimeout (_http_incoming.js:89:15)
        at Object.<anonymous> (/Users/richb/github/KoaJSExamples/stream-server-side-events/app.js:9:12)
        at GeneratorFunctionPrototype.next (native)
        at Object.respond (/Users/richb/node_modules/koa/lib/application.js:180:10)
        at GeneratorFunctionPrototype.next (native)
        at Object.<anonymous> (/Users/richb/node_modules/koa/node_modules/koa-compose/index.js:29:12)
        at GeneratorFunctionPrototype.next (native)
        at onFulfilled (/Users/richb/node_modules/co/index.js:61:19)
    
    ^C
    
  3. If I comment out the line setTimeout(Infinity) line, I get the following when I hit the server:

    richs-mbp-10715:stream-server-side-events richb$ node --harmony app.js 
    events.js:85
      throw er; // Unhandled 'error' event
            ^
    TypeError: Invalid non-string/buffer chunk
    at chunkInvalid (_stream_readable.js:384:10)
    at readableAddChunk (_stream_readable.js:140:12)
    at Subscription.Readable.push (_stream_readable.js:126:10)
    at Subscription._read (/Users/richb/github/KoaJSExamples/stream-server-side-events/db.js:30:30)
    at Subscription.Readable.read (_stream_readable.js:341:10)
    at resume_ (_stream_readable.js:725:12)
    at _stream_readable.js:717:7
    at process._tickCallback (node.js:355:11)
    
    

Yes, thanks for fixing Infinity => Number.MAX_VALUE

But... I'm still getting the exception shown in 3) above. I think the problem is in db.js line 30, where it passes this.value to the _read() function (which takes a string or buffer).

It's not clear what this code should do... Thanks

Fixed. Thanks!

👍