Special case printing Promises in Performance Track Properties (#33670)

Before:
<img width="266" alt="Screenshot 2025-06-30 at 8 32 23 AM"
src="https://github.com/user-attachments/assets/98aae5e1-4b2c-49bd-9b71-040b788c36ba"
/>

After:
<img width="342" alt="Screenshot 2025-06-30 at 8 39 17 AM"
src="https://github.com/user-attachments/assets/cd91c4a6-f6ae-4bec-9cd9-f42f4af468fe"
/>
This commit is contained in:
Sebastian Markbåge 2025-06-30 09:21:04 -04:00 committed by GitHub
parent 3cfcdfb307
commit e9cab42ece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -145,6 +145,40 @@ export function addValueToProperties(
return;
}
}
if (objectName === 'Promise') {
if (value.status === 'fulfilled') {
// Print the inner value
const idx = properties.length;
addValueToProperties(propertyName, value.value, properties, indent);
if (properties.length > idx) {
// Wrap the value or type in Promise descriptor.
const insertedEntry = properties[idx];
insertedEntry[1] =
'Promise<' + (insertedEntry[1] || 'Object') + '>';
return;
}
} else if (value.status === 'rejected') {
// Print the inner error
const idx = properties.length;
addValueToProperties(
propertyName,
value.reason,
properties,
indent,
);
if (properties.length > idx) {
// Wrap the value or type in Promise descriptor.
const insertedEntry = properties[idx];
insertedEntry[1] = 'Rejected Promise<' + insertedEntry[1] + '>';
return;
}
}
properties.push([
'\xa0\xa0'.repeat(indent) + propertyName,
'Promise',
]);
return;
}
if (objectName === 'Object') {
const proto: any = Object.getPrototypeOf(value);
if (proto && typeof proto.constructor === 'function') {