Skip to content

Commit

Permalink
fix: optional callback may prevent context from finalizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegn committed Mar 15, 2018
1 parent c85f3e1 commit f4353cc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/bridge/proxy_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export class ProxyStream {
}

registerBridge("subscribeProxyStream", function (ctx: Context, bridge: Bridge, ref: ivm.Reference<ProxyStream>, cb: ivm.Reference<Function>) {
ctx.addCallback(cb)
ctx.addReleasable(cb)
const proxyable = ref.deref({ release: true })
const stream = proxyable.stream
if (!stream) {
ctx.applyCallback(cb, ["end"])
ctx.tryCallback(cb, ["end"])
return
}
stream.on("close", function () {
Expand All @@ -79,6 +79,7 @@ registerBridge("subscribeProxyStream", function (ctx: Context, bridge: Bridge, r
ctx.tryCallback(cb, ["error", err.toString()])
})
})

registerBridge("readProxyStream", function (ctx: Context, bridge: Bridge, ref: ivm.Reference<ProxyStream>, cb: ivm.Reference<Function>) {
const proxyable = ref.deref({ release: true })
const stream = proxyable.stream
Expand Down
2 changes: 1 addition & 1 deletion v8env/middleware/google-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default function registerGoogleAnalytics() {
}
}

await fetch(gaCollectURL, {
fetch(gaCollectURL, {
method: "POST",
headers: {
"content-type": "application/x-www-form-urlencoded"
Expand Down

0 comments on commit f4353cc

Please sign in to comment.