@@ -6,6 +6,7 @@ import type { KernelMessage } from '@jupyterlab/services';
66import { BaseKernel , type IKernel } from '@jupyterlite/services' ;
77
88import type { JavaScriptExecutor } from './executor' ;
9+ import { normalizeError as normalizeUnknownError } from './errors' ;
910import {
1011 IFrameRuntimeBackend ,
1112 IRuntimeBackend ,
@@ -196,28 +197,28 @@ export class JavaScriptKernel extends BaseKernel implements IKernel {
196197 * Send an `input_reply` message.
197198 */
198199 inputReply ( content : KernelMessage . IInputReplyMsg [ 'content' ] ) : void {
199- throw new Error ( 'Not implemented ') ;
200+ this . _logUnsupportedControlMessage ( 'input_reply ') ;
200201 }
201202
202203 /**
203204 * Send an `comm_open` message.
204205 */
205206 async commOpen ( msg : KernelMessage . ICommOpenMsg ) : Promise < void > {
206- throw new Error ( 'Not implemented' ) ;
207+ this . _logUnsupportedControlMessage ( 'comm_open' , msg . content . target_name ) ;
207208 }
208209
209210 /**
210211 * Send an `comm_msg` message.
211212 */
212213 async commMsg ( msg : KernelMessage . ICommMsgMsg ) : Promise < void > {
213- throw new Error ( 'Not implemented ') ;
214+ this . _logUnsupportedControlMessage ( 'comm_msg ') ;
214215 }
215216
216217 /**
217218 * Send an `comm_close` message.
218219 */
219220 async commClose ( msg : KernelMessage . ICommCloseMsg ) : Promise < void > {
220- throw new Error ( 'Not implemented ') ;
221+ this . _logUnsupportedControlMessage ( 'comm_close ') ;
221222 }
222223
223224 /**
@@ -248,7 +249,7 @@ export class JavaScriptKernel extends BaseKernel implements IKernel {
248249 execute : async code => {
249250 const reply = await context . execute ( code ) ;
250251 if ( reply . status === 'error' ) {
251- throw this . createRuntimeInitializationError ( reply ) ;
252+ throw this . _createRuntimeInitializationError ( reply ) ;
252253 }
253254 return reply ;
254255 }
@@ -308,17 +309,13 @@ export class JavaScriptKernel extends BaseKernel implements IKernel {
308309 * Normalize unknown thrown values into Error instances.
309310 */
310311 protected normalizeError ( error : unknown ) : Error {
311- if ( error instanceof Error ) {
312- return error ;
313- }
314-
315- return new Error ( String ( error ) ) ;
312+ return normalizeUnknownError ( error , 'RuntimeError' ) ;
316313 }
317314
318315 /**
319316 * Normalize an execute reply error into an Error instance.
320317 */
321- private createRuntimeInitializationError (
318+ private _createRuntimeInitializationError (
322319 reply : KernelMessage . IExecuteReplyMsg [ 'content' ]
323320 ) : Error {
324321 const ename =
@@ -343,6 +340,28 @@ export class JavaScriptKernel extends BaseKernel implements IKernel {
343340 return error ;
344341 }
345342
343+ /**
344+ * Warn once per unsupported control message type to avoid noisy consoles.
345+ */
346+ private _logUnsupportedControlMessage (
347+ type : 'input_reply' | 'comm_open' | 'comm_msg' | 'comm_close' ,
348+ detail ?: string
349+ ) : void {
350+ if ( this . _unsupportedControlMessages . has ( type ) ) {
351+ return ;
352+ }
353+
354+ this . _unsupportedControlMessages . add ( type ) ;
355+ const suffix = detail ? ` (${ detail } )` : '' ;
356+
357+ console . warn (
358+ `[javascript-kernel] Ignoring unsupported ${ type } message${ suffix } .`
359+ ) ;
360+ }
361+
362+ private _unsupportedControlMessages = new Set <
363+ 'input_reply' | 'comm_open' | 'comm_msg' | 'comm_close'
364+ > ( ) ;
346365 private _backend : IRuntimeBackend ;
347366 private _executorFactory ?: JavaScriptKernel . IExecutorFactory ;
348367 private _runtimeMode : RuntimeMode ;
0 commit comments