Skip to content

Commit

Permalink
Fix warnings (#53)
Browse files Browse the repository at this point in the history
* fix warnings

* fix warnings
  • Loading branch information
kaibocai authored Aug 19, 2024
1 parent 5fa2bb3 commit 11c7eb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/worker/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ export class Registry {
}

_getFunctionName(fn: Function): string {
return fn.name || fn.toString().match(/function\s*([^(]*)\(/)![1];
if (fn.name) {
return fn.name;
}

const fnStr = fn.toString();
const start = fnStr.indexOf('function') + 'function'.length;
const end = fnStr.indexOf('(', start);

return fnStr.slice(start, end).trim() || '';
}
}
4 changes: 2 additions & 2 deletions test/e2e/orchestration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ describe("Durable Functions", () => {
expectedCompletionSecond += delay * 1000;
}
expect(expectedCompletionSecond).toBeDefined();
const actualCompletionSecond = state?.lastUpdatedAt?.getTime();
const actualCompletionSecond = state?.lastUpdatedAt?.getTime() ?? 0;
expect(actualCompletionSecond).toBeDefined();

expect(state);
Expand All @@ -237,7 +237,7 @@ describe("Durable Functions", () => {
expect(state?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
expect(state?.createdAt).toBeDefined();
expect(state?.lastUpdatedAt).toBeDefined();
expect(expectedCompletionSecond).toBeLessThanOrEqual(actualCompletionSecond!);
expect(expectedCompletionSecond).toBeLessThanOrEqual(actualCompletionSecond);
}, 31000);

it("should wait for external events with a timeout - true", async () => {
Expand Down

0 comments on commit 11c7eb5

Please sign in to comment.