Open Bug 1826233 Opened 1 year ago Updated 1 year ago

ErrorObject reserved 'cause' slot is aliased

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

People

(Reporter: bthrall, Unassigned)

References

(Blocks 1 open bug)

Details

ErrorObject has a reserved slot for its cause. When an initial cause is provided (as below), then the reserved slot is used for the "cause" property defined later:

const error = Error(this, { cause: "initial cause" });
Object.defineProperty(error, "cause", { get: () => "cause property" });
throw error;

However, when there is no initial cause, the property ends up in a non-reserved slot:

const error = Error(this);
Object.defineProperty(error, "cause", { get: () => "cause property" });
throw error;

Code that directly uses ErrorObject::getCause() will not see the "cause" property in this case. For example, the JS shell output does not list the cause as expected because it uses getCause().

This does not appear to affect the Firefox Developer Console.

Blocks: sm-runtime
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.