@@ -23,7 +23,7 @@ export type WorkerCapabilities = {
2323// Define the worker API interface
2424export interface WorkerAPI {
2525 init (
26- interruptBuffer ? : Uint8Array
26+ interruptBuffer : Uint8Array
2727 ) : Promise < { capabilities : WorkerCapabilities } > ;
2828 runCode (
2929 code : string
@@ -55,7 +55,7 @@ export function WorkerProvider({
5555 const interruptBuffer = useRef < Uint8Array | null > ( null ) ;
5656 const capabilities = useRef < WorkerCapabilities | null > ( null ) ;
5757 const commandHistory = useRef < string [ ] > ( [ ] ) ;
58-
58+
5959 // Track pending promises for restart-based interruption
6060 const pendingPromises = useRef < Set < ( reason : unknown ) => void > > ( new Set ( ) ) ;
6161
@@ -101,22 +101,17 @@ export function WorkerProvider({
101101
102102 // Helper function to wrap worker API calls and track pending promises
103103 // This ensures promises are rejected when the worker is terminated
104- const trackPromise = useCallback (
105- < T , > ( promise : Promise < T > ) : Promise < T > => {
106- return new Promise ( ( resolve , reject ) => {
107- // Store the reject function
108- pendingPromises . current . add ( reject ) ;
104+ const trackPromise = useCallback ( < T , > ( promise : Promise < T > ) : Promise < T > => {
105+ return new Promise ( ( resolve , reject ) => {
106+ // Store the reject function
107+ pendingPromises . current . add ( reject ) ;
109108
110- promise
111- . then ( resolve , reject )
112- . finally ( ( ) => {
113- // Remove reject function after promise settles
114- pendingPromises . current . delete ( reject ) ;
115- } ) ;
109+ promise . then ( resolve , reject ) . finally ( ( ) => {
110+ // Remove reject function after promise settles
111+ pendingPromises . current . delete ( reject ) ;
116112 } ) ;
117- } ,
118- [ ]
119- ) ;
113+ } ) ;
114+ } , [ ] ) ;
120115
121116 // Initialization effect
122117 useEffect ( ( ) => {
0 commit comments