macchiato-framework / macchiato-core

Ring style HTTP server abstraction for Node.js
MIT License
379 stars 35 forks source link

Fix `Cannot read property '_handle' of null` error when using https #32

Closed zk closed 6 years ago

zk commented 6 years ago

On macchiato-core 0.2.11 and clojurescript 1.10.339, when I provide a self-signed certificate to macchiato.server/https-server I'm getting the following error which prevents the server from handling requests:

TypeError: Cannot read property '_handle' of null
    at TLSSocket.getPeerCertificate (_tls_wrap.js:663:12)
    at /Users/zk/code/rx/target/dev/server/macchiato/http.js:23:21
    at macchiato$http$req__GT_map (/Users/zk/code/rx/target/dev/server/macchiato/http.js:27:3)
    at Server.macchiato.http.handler (/Users/zk/code/rx/target/dev/server/macchiato/http.js:346:58)
    at Server.emit (events.js:180:13)
    at parserOnIncoming (_http_server.js:642:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:117:17)

Tracked down to:

https://github.com/macchiato-framework/macchiato-core/blob/master/src/macchiato/http.cljs#L36 -> https://github.com/nodejs/node/blob/master/lib/_tls_wrap.js#L666

and it looks like this is getting clobbered by storing getPeerCertificate in the when-let and calling.

I couldn't find an appropriate test location for this. Happy to add one, although I believe that would require adding a bunch of machinery around creating a 'real' node request object and running it through the system, so understand if that's not something you all are comfortable with.

yogthos commented 6 years ago

Thanks, just pushed out 0.2.13 with the fix.

zk commented 6 years ago

Thanks!

On Wed, Jul 11, 2018 at 4:04 AM Dmitri Sotnikov notifications@github.com wrote:

Thanks, just pushed out 0.2.13 with the fix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/macchiato-framework/macchiato-core/pull/32#issuecomment-404181481, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcGjVjbvqi6xMyD6A44CKdCjSuQF-Dks5uFgXcgaJpZM4VKmFe .