You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rpc: returning an already-completed Subject never completes on the client #762
When an action returns a Subject (or BehaviorSubject) that has already completed, the client's Observable never completes, and the server throws an unhandled ReferenceError: Cannot access 'v' before initialization.
import{lastValueFrom,Subject}from'rxjs';import{DirectClient,rpc,RpcKernel}from'@deepkit/rpc';
@rpc.controller('settings')classSettingsController{
@rpc.action()finishedEvents(): Subject<string>{constevents=newSubject<string>();events.complete();returnevents;}}constkernel=newRpcKernel();kernel.registerController(SettingsController);constsettings=newDirectClient(kernel).controller<SettingsController>('settings');constevents=awaitsettings.finishedEvents();constresult=awaitPromise.race([lastValueFrom(events,{defaultValue: 'none'}),newPromise(resolve=>setTimeout(()=>resolve('pending after 1 s'),1000)),]);console.log(result);// actual: 'pending after 1 s', and on the server: ReferenceError: Cannot access 'v' before initialization// should be: 'none'
Activity