File tree 5 files changed +24
-8
lines changed
5 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export async function initNatsService({
108
108
return { buffer64 : bufferToBase64 ( buffer ) } ;
109
109
} ,
110
110
} ;
111
- return await createNatsJupyterService ( {
111
+ return await createNatsJupyterService ( {
112
112
project_id,
113
113
path,
114
114
impl,
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ const MAX_BLOB_STORE_SIZE = 100 * 1000000;
28
28
29
29
declare const localStorage : any ;
30
30
31
- import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
32
31
import * as immutable from "immutable" ;
33
32
import { Actions } from "@cocalc/util/redux/Actions" ;
34
33
import { three_way_merge } from "@cocalc/sync/editor/generic/util" ;
@@ -50,6 +49,7 @@ import type { Client } from "@cocalc/sync/client/types";
50
49
import latexEnvs from "@cocalc/util/latex-envs" ;
51
50
import { jupyterApiClient } from "@cocalc/nats/service/jupyter" ;
52
51
import { type AKV , akv } from "@cocalc/nats/sync/akv" ;
52
+ import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
53
53
54
54
const { close, required, defaults } = misc ;
55
55
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import { removeJupyterRedux } from "@cocalc/jupyter/kernel";
33
33
import { initNatsService } from "@cocalc/jupyter/kernel/nats-service" ;
34
34
import { type DKV , dkv } from "@cocalc/nats/sync/dkv" ;
35
35
import { computeServerManager } from "@cocalc/nats/compute/manager" ;
36
+ import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
36
37
37
38
// see https://github.com/sagemathinc/cocalc/issues/8060
38
39
const MAX_OUTPUT_SAVE_DELAY = 30000 ;
@@ -216,15 +217,20 @@ export class JupyterActions extends JupyterActions0 {
216
217
) ;
217
218
}
218
219
219
- private initNatsApi = async ( ) => {
220
- const service = await initNatsService ( {
220
+ private natsService ?;
221
+ private initNatsApi = reuseInFlight ( async ( ) => {
222
+ if ( this . natsService != null ) {
223
+ this . natsService . close ( ) ;
224
+ this . natsService = null ;
225
+ }
226
+ const service = ( this . natsService = await initNatsService ( {
221
227
project_id : this . project_id ,
222
228
path : this . path ,
223
- } ) ;
229
+ } ) ) ;
224
230
this . syncdb . on ( "closed" , ( ) => {
225
231
service . close ( ) ;
226
232
} ) ;
227
- } ;
233
+ } ) ;
228
234
229
235
private _first_load = async ( ) => {
230
236
const dbg = this . dbg ( "_first_load" ) ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ import { requestMany, respondMany } from "./many";
26
26
import { encodeBase64 , waitUntilConnected } from "@cocalc/nats/util" ;
27
27
28
28
const DEFAULT_TIMEOUT = 10 * 1000 ;
29
- const MONITOR_INTERVAL = 90 * 1000 ;
29
+ const MONITOR_INTERVAL = 45 * 1000 ;
30
30
31
31
// switching this is awkward since it would have to be changed in projects
32
32
// and frontends or things would hang. I'm making it toggleable just for
@@ -272,8 +272,18 @@ export class NatsService extends EventEmitter {
272
272
try {
273
273
await waitUntilConnected ( ) ;
274
274
this . emit ( "starting" ) ;
275
+
275
276
this . log ( "starting service" ) ;
276
277
const env = await getEnv ( ) ;
278
+
279
+ // close any subscriptions by this client to the subject, which might be left from previous runs of this service.
280
+ // @ts -ignore
281
+ for ( const sub of env . nc . protocol . subscriptions . subs ) {
282
+ if ( sub [ 1 ] . subject == this . subject ) {
283
+ sub [ 1 ] . close ( ) ;
284
+ }
285
+ }
286
+
277
287
if ( this . options . enableServiceFramework ?? ENABLE_SERVICE_FRAMEWORK ) {
278
288
const svcm = new Svcm ( env . nc ) ;
279
289
const service = await svcm . add ( {
Original file line number Diff line number Diff line change 1
1
/* autogenerated by the update_version script */
2
- exports . version = 1745705764 ;
2
+ exports . version = 1745732279 ;
You can’t perform that action at this time.
0 commit comments