MCPcopy Create free account
hub / github.com/sourcebot-dev/sourcebot / run

Function run

packages/web/src/features/billing/useClaimActivationCode.ts:50–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 setAttempt(0);
49
50 const run = async () => {
51 let delay = INITIAL_DELAY_MS;
52 let currentAttempt = 0;
53
54 while (!cancelledRef.current) {
55 currentAttempt++;
56 setAttempt(currentAttempt);
57
58 if (Date.now() - startedAt >= MAX_TOTAL_MS) {
59 setError({
60 statusCode: 408,
61 errorCode: 'CLAIM_POLL_TIMEOUT',
62 message: 'Timed out waiting for the activation code to be issued.',
63 });
64 setStatus('error');
65 return;
66 }
67
68 const result = await claimActivationCode(sessionId);
69 if (cancelledRef.current) {
70 return;
71 }
72
73 if (!isServiceError(result)) {
74 setActivationCode(result.activationCode);
75 setStatus('success');
76 return;
77 }
78
79 if (result.errorCode !== ACTIVATION_CODE_NOT_READY) {
80 setError(result);
81 setStatus('error');
82 return;
83 }
84
85 await new Promise((resolve) => setTimeout(resolve, delay));
86 delay = Math.min(delay * 2, MAX_DELAY_MS);
87 }
88 };
89
90 void run();
91 }, []);

Callers 3

grammar.test.tsFile · 0.85
useClaimActivationCodeFunction · 0.85

Calls 2

claimActivationCodeFunction · 0.90
isServiceErrorFunction · 0.90

Tested by

no test coverage detected