-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: cherry-pick ca76392 from upstream V8 #20467
Conversation
Original commit message: Correctly run before/after hooks for await. This fixes a bug where we didn't run before/after hooks for await when the debugger is not active, as reported downstream in nodejs#20274 Change-Id: I1948d1884c591418d87ffd1d0ccb2bebf4e908f1 Reviewed-on: https://chromium-review.googlesource.com/1039386 Commit-Queue: Benedikt Meurer <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{nodejs#52909} Refs: v8/v8@ca76392 Fixes: nodejs#20274
CI https://ci.nodejs.org/job/node-test-pull-request/14625/ /cc @nodejs/v8-update |
@MylesBorins @bmeurer said That is why I cherry-picked it. |
we could still ask for it for node's sake |
This makes sure the hooks are properly called in V8. Refs: nodejs#20274
I added a regression test. New CI https://ci.nodejs.org/job/node-test-pull-request/14641/ |
} | ||
|
||
main().then(() => assert.deepStrictEqual( | ||
asyncIds, [ '1 => 3', '1 => 4', '1 => 5', '3 => 6', '3 => 7' ])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fear these precise numbers would cause brittleness going forward. The relationships between the numbers matters but not their precise values.
@MylesBorins According to our policy we won't backport this to 6.6 and 6.7. You'll have to check with @natorion directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rubberstamp for the patch itself but I would prefer it the test conformed to the majority of our async hook tests. There are lots of utilities that should help with writing robust tests that don't rely on pushing the exact IDs into an arbitrary array.
merging this to 6.7 should be fine because it does not affect Chrome. Please open a merge request. |
Bug to track backport to 6.7: https://bugs.chromium.org/p/v8/issues/detail?id=7720 |
This PR does not fix the following: 'use strict'
const http = require('http')
const sleep = require('util').promisify(setTimeout)
const asyncHooks = require('async_hooks')
const asyncHook = asyncHooks.createHook({init, destroy})
const transactions = new Map()
asyncHook.enable()
function getCLS () {
const asyncId = asyncHooks.executionAsyncId()
return transactions.has(asyncId) ? transactions.get(asyncId) : null
}
function setCLS (value) {
const asyncId = asyncHooks.executionAsyncId()
transactions.set(asyncId, value)
}
function init (asyncId, type, triggerAsyncId, resource) {
transactions.set(asyncId, getCLS())
}
function destroy (asyncId) {
transactions.delete(asyncId)
}
http.createServer(function (req, res) {
handler().then(function (data) {
res.end(JSON.stringify(data))
}).catch(function (err) {
res.statusCode = 500
res.end(err.stack)
})
}).listen(3000)
var counter = 0
async function handler () {
setCLS(counter++)
await sleep(10)
return { cls: getCLS() }
} Correct behavior (node 8.11.1):
master (with and without this patch):
|
@mcollina thanks for pointing that out. This is independent from this patch though, so the patch should land nevertheless as far as I see it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reported as #20516. |
This was merged upstream into V8 6.7 (Thanks @MylesBorins). Since we are still at V8 6.6 on EDIT: so that it can get into a 10.x release next week. |
Comment addressed. PTAL @ofrobots |
Does this new test fail on master? Just want to check whether the test ought to assert that some of those ids are not equal to other ones. edit: Oh, never mind probably. That's what the last few assertions are for, not sure how I missed that. |
@MayaLekova @bmeurer should this land? or should we wait for a more complete revert/fix? |
@mcollina Please don't merge this, it fixes one of the cases, but seems to generally worsen the validity of the code. And the complete revert is coming soon in V8. |
@MayaLekova it is fine not to land this but it would be good to land the revert in 10.2.0 since this is a significant issue for some people. |
@BridgeAR what needs to be reverted? |
@BridgeAR which version of V8 is going to land in 10.2.0? Will have your comment in mind. |
We can land whatever the latest version of 6.6 is available
…On Mon, May 14, 2018, 2:47 AM Maya Lekova ***@***.***> wrote:
@BridgeAR <https://github.com/BridgeAR> which version of V8 is going to
land in 10.2.0? Will have your comment in mind.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20467 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAecVzMzJpjteMHu9pfm6RB8Av3PmMOGks5tyShkgaJpZM4TvWEu>
.
|
@MayaLekova Right now Node 10.x is using the V8 6.6 branch. Once V8 6.7 goes stable, we plan to bring that into the 10.x branch as well – but that is going to be no sooner than May 29-ish. For now, you can assume that the fixes are needed against V8 6.6. If the fixes/reverts you're working on can be merged to V8 6.6 – that's great, we can just roll the V8 dep and pick those up. I suspect however – given that the revert is substantial – that upstream V8 would not want to merge back. In that case we can float the changes here in Node.js as a patch. |
Thank you for the info! |
Original commit message:
Refs: v8/v8@ca76392
Fixes: #20274
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes