简体   繁体   中英

Does WebStorm not run to breakpoints on an await line?

I first set a breakpoint on the let line, the if statement line, and the await line.

Assuming I break on the let line and then press run to next breakpoint, the code does hit the next breakpoint.

However, if I'm on the let line, I can press step over and go to the const test line, hit step over again, and it jumps over the if statement and goes to the const test2 line. Pushing run does not lead to the await line and pushing step over or into after reaching test2 results in me going into other code.

As a former Visual Studio user this is really strange behavior to me. I don't know if it's a TypeScript peculiarity or something to do with TypeScript/JavaScript and the async/await construct.

I've rebuilt several times just to verify that my code matches what's running on the server.

I thought that await line should get hit, then it should suspend the rest of the function.

public async requestList() {

    let res = this.cache.get(serializedParam);

    const test = 'test';
    if (!res) {
        const test2 = 'test2';
        const _res = await Function(param);
     }

The issue looks similar to WEB-39041 , please follow it for updates. It only occurs when using sourcemaps, stepping works fine when debugging pure Javascript

Try this:

Declare the function as 'async' in order to use await. The function needs tobe async.

async requestList() {
    let res = this.cache.get(serializedParam);

    const test = 'test';
    if (!res) {
        const test2 = 'test2';
        const _res = await Function(param);
     }
}

async  Function(param){

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM