0

I have some sample JS code that I am running in the browser and it uses Promise. I would like to debug the source code of the JS engine along with debugging my source code. Is there a way I can attach the JS engine source code in chrome developer tools?

UPDATE:

 const buyFlightTicket = () => {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                const error = false;
                if (error) {
                    reject("Sorry your payment was not successful")
                } else {
                    resolve("Thank you, your payment was successful");
                }
            }, 3000)
        })
    }
    buyFlightTicket()
        .then((success) => console.log(success))
        .catch((error) => console.log(error));

I have this piece of code and I want to understand what the Promise() function is doing with the function I am passing it as argument

9
  • The developper tools in chrome include a debugger, is there something you would like to do that's not possible with that? Commented Aug 14, 2020 at 10:54
  • @MathieuK. — They said they wanted to debug V8 itself, not just JS running on it. Commented Aug 14, 2020 at 10:55
  • I would like to be able to put a breakpoint inside the Engine source code and do some debugging Commented Aug 14, 2020 at 10:56
  • my bad, I didn't get that. Commented Aug 14, 2020 at 10:58
  • 1
    Yes, the promise constructor passes in two resolving functions as arguments to the executor, which you can (should) call to resolve/reject the promise later. I would suggest you read some promise tutorials to learn the basics, if you want the gory details (or because you learn better that way) I'd suggest you rather read the EcmaScript specification than the source code of an implementation. Commented Aug 14, 2020 at 14:31

1 Answer 1

1

V8 developer here. To debug V8 itself, you need a C++ debugger (like GDB or LLDB or Visual Studio's debugger), along with a Debug build of Chrome or V8. Chrome DevTools can't debug V8's internals.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.