Skip to content

Commit 2c261fc

Browse files
SalazareoCopilot
andauthored
fix: extensions (#2881)
Co-authored-by: Copilot <copilot@github.com>
1 parent 0ffb7d3 commit 2c261fc

3 files changed

Lines changed: 71 additions & 17 deletions

File tree

src/backend/controllers/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const PuterController =
6363
public onServerShutdown() {
6464
return;
6565
}
66-
public getReportedCosts(): Record<string, unknown>[] {
66+
public async getReportedCosts() {
6767
return [];
6868
}
6969
public registerRoutes(_router: PuterRouter) {}

src/backend/extensions.ts

Lines changed: 69 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,19 @@ export const extension = {
278278
get: (_target: object, prop: string) => {
279279
const proxiedObj = clientsContainers[prop];
280280
if (!proxiedObj) {
281-
throw new Error(
282-
`Called before initialization: ${name}.${prop}`,
283-
);
281+
const proxyProxyHandler = {
282+
get: (_target2: object, prop2: string) => {
283+
const proxiedObj2 =
284+
clientsContainers[prop][prop2];
285+
if (!proxiedObj2) {
286+
throw new Error(
287+
`extension.import('client:${prop}') missing property '${prop2}'`,
288+
);
289+
}
290+
return proxiedObj2;
291+
},
292+
};
293+
return new Proxy({}, proxyProxyHandler) as object;
284294
}
285295
return proxiedObj;
286296
},
@@ -292,10 +302,21 @@ export const extension = {
292302
const proxyHandler = {
293303
get: (_target: object, prop: string) => {
294304
const proxiedObj = storesContainers[prop];
305+
295306
if (!proxiedObj) {
296-
throw new Error(
297-
`Called before initialization: ${name}.${prop}`,
298-
);
307+
const proxyProxyHandler = {
308+
get: (_target2: object, prop2: string) => {
309+
const proxiedObj2 =
310+
clientsContainers[prop][prop2];
311+
if (!proxiedObj2) {
312+
throw new Error(
313+
`extension.import('client:${prop}') missing property '${prop2}'`,
314+
);
315+
}
316+
return proxiedObj2;
317+
},
318+
};
319+
return new Proxy({}, proxyProxyHandler) as object;
299320
}
300321
return proxiedObj;
301322
},
@@ -307,10 +328,21 @@ export const extension = {
307328
const proxyHandler = {
308329
get: (_target: object, prop: string) => {
309330
const proxiedObj = servicesContainers[prop];
331+
310332
if (!proxiedObj) {
311-
throw new Error(
312-
`Called before initialization: ${name}.${prop}`,
313-
);
333+
const proxyProxyHandler = {
334+
get: (_target2: object, prop2: string) => {
335+
const proxiedObj2 =
336+
clientsContainers[prop][prop2];
337+
if (!proxiedObj2) {
338+
throw new Error(
339+
`extension.import('client:${prop}') missing property '${prop2}'`,
340+
);
341+
}
342+
return proxiedObj2;
343+
},
344+
};
345+
return new Proxy({}, proxyProxyHandler) as object;
314346
}
315347
return proxiedObj;
316348
},
@@ -322,10 +354,21 @@ export const extension = {
322354
const proxyHandler = {
323355
get: (_target: object, prop: string) => {
324356
const proxiedObj = controllersContainers[prop];
357+
325358
if (!proxiedObj) {
326-
throw new Error(
327-
`Called before initialization: ${name}.${prop}`,
328-
);
359+
const proxyProxyHandler = {
360+
get: (_target2: object, prop2: string) => {
361+
const proxiedObj2 =
362+
clientsContainers[prop][prop2];
363+
if (!proxiedObj2) {
364+
throw new Error(
365+
`extension.import('client:${prop}') missing property '${prop2}'`,
366+
);
367+
}
368+
return proxiedObj2;
369+
},
370+
};
371+
return new Proxy({}, proxyProxyHandler) as object;
329372
}
330373
return proxiedObj;
331374
},
@@ -337,10 +380,21 @@ export const extension = {
337380
const proxyHandler = {
338381
get: (_target: object, prop: string) => {
339382
const proxiedObj = driversContainers[prop];
383+
340384
if (!proxiedObj) {
341-
throw new Error(
342-
`Called before initialization: ${name}.${prop}`,
343-
);
385+
const proxyProxyHandler = {
386+
get: (_target2: object, prop2: string) => {
387+
const proxiedObj2 =
388+
clientsContainers[prop][prop2];
389+
if (!proxiedObj2) {
390+
throw new Error(
391+
`extension.import('client:${prop}') missing property '${prop2}'`,
392+
);
393+
}
394+
return proxiedObj2;
395+
},
396+
};
397+
return new Proxy({}, proxyProxyHandler) as object;
344398
}
345399
return proxiedObj;
346400
},

src/backend/services/fs/FSService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3060,7 +3060,7 @@ export class FSService extends PuterService {
30603060
{},
30613061
);
30623062
} catch {
3063-
// Non-critical — the response is the source of truth.
3063+
console.warn('missing event emissions');
30643064
}
30653065
}
30663066

0 commit comments

Comments
 (0)