KR34T1V
KR34T1V

Reputation: 493

"rejected promise not handled within 1 second" vscode API

So I have been working on my first vscode extension and all has gone well until the debugger would stop my the execution of my extension.

I am fairly new to javascript so maybe I am missing something on "thenables" but here is my problem.

I run my extension using keyboard shortcuts eg. "ctrl + alt + o" and it runs fine, but the moment I change "activeTextEditor" I get "rejected promise not handled within 1 second" in my debug console.

The suspected section is this:

    const checkOutHeader = (history) => {
    console.log("Path: checkOutHeader");
    activeTextEditor.edit((editor) => {
        editor.replace(new vscode.Range(0,0,10,100), commentHeader(
            populateCheckOutHeader(head.out, history).substring(1), languageId));
    }).then((none)=>{
        console.log("We are here!");
        saveFile();
    });
};

This is based of the path my extension logged in the debug console:

CheckoutHeader: Now active!
Path: getHeaderConfig
lang: makefile
Path: supportHeaderLanguage
Path: checkInHandler
Path: getCurrentHeader
Path: getHistoryFileStatus
Path: getHeaderHistory
Path: getHistoryFileName
Path: getHistoryFileStatus
Path: getHistoryTimeIn
Path: getHistoryInBy
Path: getHistoryTimeOut
Path: getHistoryOutBy
Path: checkInHeader
rejected promise not handled within 1 second

I have read that some people claimed it was c++tools but I do not have that extension installed.

Thanks!

Upvotes: 1

Views: 3294

Answers (1)

KR34T1V
KR34T1V

Reputation: 493

Turned out that the promise was never the problem despite the debug feedback.

I had set global variables in the top of my file

const activeTextEditor = vscode.window.activeTextEditor;
const document = activeTextEditor.document;
const languageId = document.languageId;

to make accessing the API's more convenient, but as a result of them only being initiated when I run the extension the first time whenever I would change the "activeTextEditor" the variable would still contain old information causing the crash..

Upvotes: 2

Related Questions