Skip to content

Commit 5134e7d

Browse files
[ONCALL-143] hotfix: [context not found] add delay for channels creation (#225)
* fix: add delay to sync channels creation * fix: await while exposing --------- Co-authored-by: rohanmathur91 <[email protected]>
1 parent 1fb012b commit 5134e7d

File tree

2 files changed

+37
-11
lines changed

2 files changed

+37
-11
lines changed

src/renderer/actions/local-sync/fs-manager.rpc-service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import { RPCServiceOverIPC } from "renderer/lib/RPCServiceOverIPC";
22
import { FsManager } from "./fs-manager";
33

4+
async function waitForInit() {
5+
return new Promise((resolve) => {
6+
setTimeout(() => resolve(""), 800);
7+
});
8+
}
9+
410
export class FsManagerRPCService extends RPCServiceOverIPC {
511
private fsManager: FsManager;
612

7-
constructor(readonly rootPath: string, readonly exposedWorkspacePaths: Map<string,unknown>) {
13+
constructor(
14+
readonly rootPath: string,
15+
readonly exposedWorkspacePaths: Map<string, unknown>
16+
) {
817
super(`local_sync: ${rootPath}`);
918
this.fsManager = new FsManager(rootPath, this.exposedWorkspacePaths);
1019
}
@@ -17,6 +26,7 @@ export class FsManagerRPCService extends RPCServiceOverIPC {
1726
try {
1827
await this.fsManager.init();
1928
} catch (error) {
29+
// console.log("FsManagerRPCService init", error);
2030
throw new Error(
2131
`Failed to initialize FsManager for ${this.rootPath}: ${
2232
error instanceof Error ? error.message : String(error)
@@ -140,5 +150,8 @@ export class FsManagerRPCService extends RPCServiceOverIPC {
140150
"createCollectionFromCompleteRecord",
141151
this.fsManager.createCollectionFromCompleteRecord.bind(this.fsManager)
142152
);
153+
154+
// hack
155+
await waitForInit();
143156
}
144157
}

src/renderer/lib/RPCServiceOverIPC.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,38 @@ export class RPCServiceOverIPC {
2727
exposedMethodName: string,
2828
method: (..._args: any[]) => Promise<any>
2929
) {
30-
// const channelName = this.generateChannelNameForMethod(method);
3130
const channelName = `${this.RPC_CHANNEL_PREFIX}${exposedMethodName}`;
32-
console.log("DBG-1: exposing channel", channelName, Date.now());
31+
// console.log("DBG-1: exposing channel", channelName, Date.now());
3332
ipcRenderer.on(channelName, async (_event, args) => {
34-
console.log(
35-
"DBG-1: received event on channel",
36-
channelName,
37-
_event,
38-
args
39-
);
33+
// console.log(
34+
// "DBG-1: received event on channel",
35+
// channelName,
36+
// _event,
37+
// args,
38+
// Date.now()
39+
// );
4040
try {
4141
const result = await method(...args);
42-
console.log("DBG-2: result in method", result, exposedMethodName);
42+
43+
// console.log(
44+
// "DBG-2: result in method",
45+
// result,
46+
// channelName,
47+
// _event,
48+
// args,
49+
// exposedMethodName,
50+
// Date.now()
51+
// );
4352
ipcRenderer.send(`reply-${channelName}`, {
4453
success: true,
4554
data: result,
4655
});
4756
} catch (error: any) {
48-
console.log("DBG-2: error in method", error);
57+
// console.log(
58+
// `DBG-2: reply-${channelName} error in method`,
59+
// error,
60+
// Date.now()
61+
// );
4962
ipcRenderer.send(`reply-${channelName}`, {
5063
success: false,
5164
data: error.message,

0 commit comments

Comments
 (0)