Skip to content

Commit fa1d420

Browse files
committed
fix(tmp): tmp setup
1 parent 88bc6eb commit fa1d420

File tree

7 files changed

+56
-5
lines changed

7 files changed

+56
-5
lines changed

src/contexts/backend/backend.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ function BackendProvider({ children }: { children: React.ReactNode }) {
331331
isDbInitialized,
332332
isSyncInitialized,
333333
isReady,
334+
testCase: async () => {
335+
console.log('----test case clic', backgroundWorkerInstance);
336+
await backgroundWorkerInstance.testCase();
337+
},
334338
} as BackendProviderContextType),
335339
[
336340
isReady,

src/features/ipfs/Drive/BackendStatus.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ function BackendStatus() {
7070
(store) => store.backend
7171
);
7272

73+
const { testCase } = useBackend();
74+
7375
const downloadLogsOnClick = () => {
7476
const logs = cyblog.getLogs();
7577
downloadJson(logs, `cyblog_${new Date().toISOString()}.json`);
7678
};
7779

80+
const testOnClick = async () => {
81+
await testCase();
82+
};
83+
7884
return (
7985
<Display color={Colors.GREEN}>
8086
<div className={styles.list}>
@@ -117,6 +123,9 @@ function BackendStatus() {
117123
<Button small onClick={downloadLogsOnClick}>
118124
🐞 download logs
119125
</Button>
126+
<Button small onClick={testOnClick}>
127+
test abort signal
128+
</Button>
120129
</div>
121130
</div>
122131
</Display>

src/services/QueueManager/QueueManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,15 @@ class QueueManager {
190190
}).pipe(
191191
timeout({
192192
each: settings.timeout,
193-
with: () =>
193+
with: (timeoutInfo) =>
194194
throwError(() => {
195+
console.log(
196+
'----timeout triggered',
197+
timeoutInfo.lastValue?.cid,
198+
timeoutInfo.lastValue?.source
199+
);
195200
controller?.abort('timeout');
201+
196202
return new QueueItemTimeoutError(settings.timeout);
197203
}),
198204
}),

src/services/backend/workers/background/worker.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,34 @@ const createBackgroundWorkerApi = () => {
303303
restartSync: (name: SyncEntryName) => syncService.restart(name),
304304
setParams: (params: Partial<SyncServiceParams>) =>
305305
params$.next({ ...params$.value, ...params }),
306+
307+
testCase: () => {
308+
console.log('>>> test case fired');
309+
(async () => {
310+
const controller = new AbortController();
311+
setTimeout(() => {
312+
controller.abort();
313+
console.log('>>> abort triggered');
314+
}, 1000); // Abort after 1 second
315+
316+
try {
317+
const response = await fetch(
318+
'https://gateway.ipfs.cybernode.ai/ipfs/QmPRHHTeWzgBoRvbYMg4Q3ZVviu3VDP5rTPLgXotYpiuba',
319+
{
320+
method: 'GET',
321+
signal: controller.signal,
322+
}
323+
);
324+
// Handle the response
325+
} catch (error) {
326+
if (error.name === 'AbortError') {
327+
console.log('>>> Fetch aborted');
328+
} else {
329+
console.error('>>> Fetch error:', error);
330+
}
331+
}
332+
})();
333+
},
306334
};
307335
};
308336

src/services/backend/workers/factoryMethods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type WorkerType = SharedWorker | Worker;
55

66
const isSharedWorkersSupported = typeof SharedWorker !== 'undefined';
77

8-
const isSharedWorkerUsed = isSharedWorkersSupported && !process.env.IS_DEV;
8+
const isSharedWorkerUsed = isSharedWorkersSupported; //&& !process.env.IS_DEV;
99

1010
// apply serializers for custom types
1111
function installTransferHandlers() {

src/services/ipfs/utils/utils-ipfs.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,10 @@ const fetchIPFSContentFromGateway = async (
170170
? await fetchIPFSContentMeta(cid, node, controller?.signal)
171171
: emptyMeta;
172172

173+
controller?.signal &&
174+
controller?.signal.onabort((ev) => {
175+
console.log('-----aborted', cid);
176+
});
173177
const contentUrl = `${CYBER_GATEWAY_URL}/ipfs/${cid}`;
174178
const response = await fetch(contentUrl, {
175179
method: 'GET',

webpack.config.dev.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ module.exports = merge(commonConfig, {
1919
historyApiFallback: true,
2020
},
2121
plugins: [
22-
new ReactRefreshWebpackPlugin({
23-
overlay: false,
24-
}),
22+
// new ReactRefreshWebpackPlugin({
23+
// overlay: false,
24+
// }),
2525
new webpack.DefinePlugin({
2626
...commonConfig.plugins.find(
2727
(plugin) => plugin.constructor.name === 'DefinePlugin'

0 commit comments

Comments
 (0)