@@ -233,7 +233,7 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
233233
234234 // Override save behavior to avoid transferring the buffer across the wire 3 times
235235 if ( saveWithReducedCommunication ) {
236- this . setSaveDelegate ( ) . catch ( console . error ) ;
236+ this . setSaveDelegate ( ) . catch ( error => this . _notebookLogService . error ( 'WorkingCopyModel' , `Failed to set save delegate: ${ error } ` ) ) ;
237237 }
238238 }
239239
@@ -247,7 +247,12 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
247247
248248 if ( ! serializer ) {
249249 this . _notebookLogService . info ( 'WorkingCopyModel' , 'No serializer found for notebook model, checking if provider still needs to be resolved' ) ;
250- serializer = await this . getNotebookSerializer ( ) ;
250+ serializer = await this . getNotebookSerializer ( ) . catch ( error => {
251+ this . _notebookLogService . error ( 'WorkingCopyModel' , `Failed to get notebook serializer: ${ error } ` ) ;
252+ // The serializer was set initially but somehow is no longer available
253+ this . save = undefined ;
254+ throw new NotebookSaveError ( 'Failed to get notebook serializer' ) ;
255+ } ) ;
251256 }
252257
253258 if ( token . isCancellationRequested ) {
@@ -257,11 +262,11 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
257262 const stat = await serializer . save ( this . _notebookModel . uri , this . _notebookModel . versionId , options , token ) ;
258263 return stat ;
259264 } catch ( error ) {
260- if ( ! token . isCancellationRequested ) {
265+ if ( ! token . isCancellationRequested && error . name !== 'Canceled' ) {
261266 type notebookSaveErrorData = {
262267 isRemote : boolean ;
263268 isIPyNbWorkerSerializer : boolean ;
264- error : Error ;
269+ error : string ;
265270 } ;
266271 type notebookSaveErrorClassification = {
267272 owner : 'amunger' ;
@@ -271,10 +276,11 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
271276 error : { classification : 'SystemMetaData' ; purpose : 'PerformanceAndHealth' ; comment : 'Info about the error that occurred' } ;
272277 } ;
273278 const isIPynb = this . _notebookModel . viewType === 'jupyter-notebook' || this . _notebookModel . viewType === 'interactive' ;
279+ const errorMessage = error . name === 'NotebookSaveError' ? error . message : 'Unknown error' ;
274280 this . _telemetryService . publicLogError2 < notebookSaveErrorData , notebookSaveErrorClassification > ( 'notebook/SaveError' , {
275281 isRemote : this . _notebookModel . uri . scheme === Schemas . vscodeRemote ,
276282 isIPyNbWorkerSerializer : isIPynb && this . _configurationService . getValue < boolean > ( 'ipynb.experimental.serialization' ) ,
277- error : error
283+ error : errorMessage
278284 } ) ;
279285 }
280286
@@ -313,7 +319,8 @@ export class NotebookFileWorkingCopyModel extends Disposable implements IStoredF
313319 async getNotebookSerializer ( ) : Promise < INotebookSerializer > {
314320 const info = await this . _notebookService . withNotebookDataProvider ( this . notebookModel . viewType ) ;
315321 if ( ! ( info instanceof SimpleNotebookProviderInfo ) ) {
316- throw new Error ( 'CANNOT open file notebook with this provider' ) ;
322+ const message = 'CANNOT open notebook with this provider' ;
323+ throw new NotebookSaveError ( message ) ;
317324 }
318325
319326 return info . serializer ;
@@ -348,3 +355,10 @@ export class NotebookFileWorkingCopyModelFactory implements IStoredFileWorkingCo
348355}
349356
350357//#endregion
358+
359+ class NotebookSaveError extends Error {
360+ constructor ( message : string ) {
361+ super ( message ) ;
362+ this . name = 'NotebookSaveError' ;
363+ }
364+ }
0 commit comments