Skip to content

invalid URL escape panic when creating new file in WSL #1096

Closed
@jakebailey

Description

@jakebailey

Honestly, this seems like a VS Code / WSL bug more than anything, but I was in the editor, then created a new file with code-insiders path/to/file, and got:

panic handling request textDocument/didOpen parse "untitled://wsl%2Bubuntu/home/jabaile/work/TypeScript/tests/cases/compiler/missingDiscriminants.ts": invalid URL escape "%2B" goroutine 34 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:26 +0x5e
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1.1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:357 +0x5d
panic({0xa39000?, 0xc010f56510?})
	runtime/panic.go:792 +0x132
github.com/microsoft/typescript-go/internal/core.Must[...](...)
	github.com/microsoft/typescript-go/internal/core/core.go:408
github.com/microsoft/typescript-go/internal/ls.DocumentURIToFileName({0xc0017d8070?, 0x0?})
	github.com/microsoft/typescript-go/internal/ls/converters.go:84 +0x25a
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleDidOpen(0xc0001aea20, {0xa8000a?, 0xc002a09d70?}, 0x414a1e?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:598 +0x46
github.com/microsoft/typescript-go/internal/lsp.(*Server).handleRequestOrNotification(0x7907a4e955a8?, {0xccd890?, 0xc0000d8a50?}, 0xc000600808?)
	github.com/microsoft/typescript-go/internal/lsp/server.go:464 +0x10e
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:363 +0x75
github.com/microsoft/typescript-go/internal/lsp.(*Server).dispatchLoop(0xc0001aea20, {0xccd890?, 0xc000218000?})
	github.com/microsoft/typescript-go/internal/lsp/server.go:379 +0x4bb
github.com/microsoft/typescript-go/internal/lsp.(*Server).Run.func1()
	github.com/microsoft/typescript-go/internal/lsp/server.go:255 +0x1f
golang.org/x/sync/errgroup.(*Group).add.func1()
	golang.org/x/sync@v0.14.0/errgroup/errgroup.go:130 +0x7e
created by golang.org/x/sync/errgroup.(*Group).add in goroutine 1
	golang.org/x/sync@v0.14.0/errgroup/errgroup.go:98 +0x76

And alas:

[Trace - 9:01:17 AM] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "untitled://wsl%2Bubuntu/home/jabaile/work/TypeScript/tests/cases/compiler/missingDiscriminants.ts",
        "languageId": "typescript",
        "version": 1,
        "text": ""
    }
}

This crashed 5 times, as VS Code kept sending this URI ☹

It shouldn't crash. Probably, worth doing some weird fixup on to turn into a file://. I dunno.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CrashDomain: EditorRelated to the LSP server, editor experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions