@@ -85,10 +85,13 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
8585
8686 private _evalResultProperties = new Map < number , xdebug . EvalResultProperty > ( ) ;
8787
88+ private cookies : string [ ] = [ ] ;
89+
8890 public constructor ( ) {
8991 super ( ) ;
9092
9193 const api = new AtelierAPI ( ) ;
94+ this . cookies = api . cookies ;
9295 if ( ! api . active ) {
9396 throw new Error ( "Connection not active" ) ;
9497 }
@@ -114,7 +117,11 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
114117 supportsStepBack : false ,
115118 } ;
116119
117- const socket = new WebSocket ( this . _url ) ;
120+ const socket = new WebSocket ( this . _url , {
121+ headers : {
122+ cookie : this . cookies ,
123+ } ,
124+ } ) ;
118125
119126 const disposeConnection = ( error ?: Error ) : void => {
120127 this . sendEvent ( new ThreadEvent ( "exited" , this . _connection . id ) ) ;
@@ -130,24 +137,30 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
130137 this . sendEvent ( new OutputEvent ( data , "stdout" ) ) ;
131138 } ) ;
132139
133- await this . _connection . waitForInitPacket ( ) ;
140+ try {
141+ await this . _connection . waitForInitPacket ( ) ;
134142
135- await this . _connection . sendFeatureSetCommand ( "max_data" , 8192 ) ;
136- await this . _connection . sendFeatureSetCommand ( "max_children" , 32 ) ;
137- await this . _connection . sendFeatureSetCommand ( "max_depth" , 2 ) ;
138- await this . _connection . sendFeatureSetCommand ( "notify_ok" , 1 ) ;
143+ await this . _connection . sendFeatureSetCommand ( "max_data" , 8192 ) ;
144+ await this . _connection . sendFeatureSetCommand ( "max_children" , 32 ) ;
145+ await this . _connection . sendFeatureSetCommand ( "max_depth" , 2 ) ;
146+ await this . _connection . sendFeatureSetCommand ( "notify_ok" , 1 ) ;
139147
140- this . sendResponse ( response ) ;
148+ this . sendResponse ( response ) ;
141149
142- this . sendEvent ( new InitializedEvent ( ) ) ;
150+ this . sendEvent ( new InitializedEvent ( ) ) ;
151+ } catch ( error ) {
152+ response . success = false ;
153+ response . message = "Debugger can not start" ;
154+ this . sendResponse ( response ) ;
155+ }
143156 }
144157
145158 protected async launchRequest ( response : DebugProtocol . LaunchResponse , args : LaunchRequestArguments ) : Promise < void > {
146159 // this._args = args;
147160
148161 try {
149162 const debugTarget = `${ this . _namespace } :${ args . program } ` ;
150- await this . _connection . sendFeatureSetCommand ( "debug_target" , debugTarget ) ;
163+ await this . _connection . sendFeatureSetCommand ( "debug_target" , debugTarget , true ) ;
151164
152165 this . _debugTargetSet . notify ( ) ;
153166 } catch ( error ) {
0 commit comments