Skip to content
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

console: print promise details #4524

Merged
merged 4 commits into from
Mar 30, 2020
Merged

console: print promise details #4524

merged 4 commits into from
Mar 30, 2020

Conversation

mhvsa
Copy link
Contributor

@mhvsa mhvsa commented Mar 29, 2020

Related with #3165

Current:

Promise {}
Promise {}
Promise {}

Target:

Promise { <pending> }
Promise { 2 }
Promise { <rejected> 'rejection reason' }

@@ -102,6 +102,8 @@ declare global {

formatError: (e: Error) => string;

getPromiseDetails(promise: Promise<unknown>) : [number, unknown];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be typed a lot more specifically. If the second argument of the tuple is the value of the promise, then:

Suggested change
getPromiseDetails(promise: Promise<unknown>) : [number, unknown];
getPromiseDetails<T>(promise: Promise<T>) : [number, T];

Also provide some JSDoc please, so this is easily documented.

core/bindings.rs Outdated
res.set(
context,
v8::Integer::new(scope, 0).into(),
promise.result(scope).into(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run cargo clippy to pick up these linting errors.

core/bindings.rs Outdated
mut rv: v8::ReturnValue,
) {
if !args.get(0).is_promise() {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how this code is going to behave at runtime with this. It shouldn't silently fail. We should effectively raise a JS error with appropriate information, like a TypeError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returned undefined in that way; however I like the idea of throwing TypeError more.

@mhvsa mhvsa force-pushed the print_promises branch 2 times, most recently from decb086 to 80df495 Compare March 30, 2020 19:46
@mhvsa mhvsa changed the title WIP: console: print promise details console: print promise details Mar 30, 2020
@mhvsa
Copy link
Contributor Author

mhvsa commented Mar 30, 2020

Review Ready
@ry @bartlomieju @kitsonk

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 30fdf6d into denoland:master Mar 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants