From ffb0318e4a2427abd0ab9c77ab48ef57357b0dc0 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Thu, 11 May 2023 14:08:17 +0100 Subject: fix(console): handle error when inspecting promise-like (#19083) Fixes https://discord.com/channels/684898665143206084/684911491035430919/1105900195406958672. This was caused by: - A `TypeError` from `core.getPromiseDetails()` for promise-likes which also lead to that code path. - Swallowing internal formatting errors by returning `undefined`. I've made it so that a special message is formatted in that case instead (note that this case is fixed now): ![image](https://github.com/denoland/deno/assets/29990554/65bb9612-60b2-4e31-bf5e-e20976601593) --- cli/tests/unit/console_test.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts index 0bd53dc77..c4f2f64a4 100644 --- a/cli/tests/unit/console_test.ts +++ b/cli/tests/unit/console_test.ts @@ -2235,6 +2235,13 @@ Deno.test(function inspectWithPrototypePollution() { } }); +Deno.test(function inspectPromiseLike() { + assertEquals( + Deno.inspect(Object.create(Promise.prototype)), + "Promise { }", + ); +}); + Deno.test(function inspectorMethods() { console.timeStamp("test"); console.profile("test"); -- cgit v1.2.3