@@ -12,6 +12,7 @@ import * as semver from "semver"
1212import * as vscode from "vscode"
1313import * as ws from "ws"
1414import { makeCoderSdk } from "./api"
15+ import { errToStr } from "./api-helper"
1516import { Commands } from "./commands"
1617import { getHeaderCommand } from "./headers"
1718import { SSHConfig , SSHValues , mergeSSHConfigValues } from "./sshConfig"
@@ -238,7 +239,8 @@ export class Remote {
238239 try {
239240 const baseUrl = new URL ( baseUrlRaw )
240241 const proto = baseUrl . protocol === "https:" ? "wss:" : "ws:"
241- const socket = new ws . WebSocket ( new URL ( `${ proto } //${ baseUrl . host } ${ path } ` ) , {
242+ const socketUrlRaw = `${ proto } //${ baseUrl . host } ${ path } `
243+ const socket = new ws . WebSocket ( new URL ( socketUrlRaw ) , {
242244 headers : {
243245 "Coder-Session-Token" : token ,
244246 } ,
@@ -249,15 +251,15 @@ export class Remote {
249251 const log = JSON . parse ( buf . toString ( ) ) as ProvisionerJobLog
250252 writeEmitter . fire ( log . output + "\r\n" )
251253 } )
252- socket . on ( "error" , ( err ) => {
253- reject ( err )
254+ socket . on ( "error" , ( error ) => {
255+ reject ( new Error ( `Failed to open web socket to ${ socketUrlRaw } : ${ errToStr ( error , "no further details" ) } ` ) )
254256 } )
255257 socket . on ( "close" , ( ) => {
256258 resolve ( )
257259 } )
258260 } catch ( error ) {
259261 // If this errors, it is probably a malformed URL.
260- reject ( error )
262+ reject ( new Error ( `Failed to open web socket to ${ baseUrlRaw } : ${ errToStr ( error , "no further details" ) } ` ) )
261263 }
262264 } )
263265 writeEmitter . fire ( "Build complete" )
0 commit comments