Repository navigation
EnvDeleter should return true #7960
Description
Activity
I'm inclined to say it's a V8 bug because node.js follows the contract for delete interceptors to the letter. From the doc comment for
GenericNamedPropertyDeleterCallback:The return value is true if the property could be deleted and false otherwise.
- addedv8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.
on Aug 3, 2016 Yes, the callback should return true 'if the property could be deleted'. The question is: what does it mean that it could be deleted? In JavaScript world this means that the property should not be non-configurable (and it may not even exist). Compare it with
'use strict'; var o = {}; console.log(delete o.nonExistentProperty);that returns
true. That's why I believeEnvDeletershould returntruefor any environment variable as well.Can you open a V8 bug? I'd like to hear what they have to say.
OK, I have filled https://bugs.chromium.org/p/v8/issues/detail?id=5260
We can use
info.ShouldThrowOnError()in EnvDeleter to determine if we're in strict mode.@fhinkel What would you do in that case though? Users can't freeze/seal
process.envor put non-configurable properties on it so I think the only thing to do for the deleter is to return true instead of false.I misunderstood, I thought the issue is, that we should throw. If
process.envnever has non-configurable properties I guess we can always returntrue.Thank you for a quick fix!
Reacted by James M Snell- added a commit that references this issue
on Aug 10, 2016 - added a commit that references this issue
on Jul 27, 2026
Consider the following test-case:
It is weird to see
deleteoperator to returnfalseit strict-mode. It should returntrueor throw an error there. While this seems to be also a bug in V8 (it should throw an error when the deleter callback returns false in strict-mode) the implementation ofEnvDeleter(insrc/node.cc) should be fixed as well. It should returntruefor any environment variable (even the non-existing ones) to match the behaviour ofdeleteoperator that is supposed to returntrueunless non-configurable property is being deleted.