-
Notifications
You must be signed in to change notification settings - Fork 17
Fix ENSDb SDK builder for "concrete" ENSIndexer Schema #1832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
1661f1c
7f4b83b
7b8c1a7
e9d496a
eac1297
13f969a
b45dea9
f18bd34
a9a08f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@ensnode/ensdb-sdk": minor | ||
| --- | ||
|
|
||
| Fixed `buildConcreteEnsIndexerSchema` function by replacing the incomplete cloning approach with working mutation approach. | ||
|
tk-o marked this conversation as resolved.
Outdated
tk-o marked this conversation as resolved.
Outdated
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -189,35 +189,41 @@ async function pollIndexingStatus( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ensIndexerSchemaName: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeoutMs: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const client = new (await import("@ensnode/ensdb-sdk")).EnsDbReader( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ensDbUrl, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ensIndexerSchemaName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { EnsDbReader } = await import("@ensnode/ensdb-sdk"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const ensDbClient = new EnsDbReader(ensDbUrl, ensIndexerSchemaName); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const start = Date.now(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log("Polling indexing status..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while (Date.now() - start < timeoutMs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkAborted(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const snapshot = await client.getIndexingStatusSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (snapshot !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const omnichainStatus = snapshot.omnichainSnapshot.omnichainStatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log(`Omnichain status: ${omnichainStatus}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| omnichainStatus === OmnichainIndexingStatusIds.Following || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| omnichainStatus === OmnichainIndexingStatusIds.Completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log("Indexing reached target status"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while (Date.now() - start < timeoutMs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| checkAborted(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const snapshot = await ensDbClient.getIndexingStatusSnapshot(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (snapshot !== undefined) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const omnichainStatus = snapshot.omnichainSnapshot.omnichainStatus; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log(`Omnichain status: ${omnichainStatus}`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| omnichainStatus === OmnichainIndexingStatusIds.Following || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| omnichainStatus === OmnichainIndexingStatusIds.Completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| log("Indexing reached target status"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // indexer may not be ready yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // indexer may not be ready yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await new Promise((r) => setTimeout(r, 3000)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await new Promise((r) => setTimeout(r, 3000)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error(`Indexing did not complete within ${timeoutMs / 1000}s`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("Closing ENSDb client..."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - DrizzleClient.$client is not typed to have an `end` method, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // but in practice it does (e.g. pg's Client does). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await ensDbClient.ensDb.$client.end(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
tk-o marked this conversation as resolved.
tk-o marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("ENSDb client closed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+222
to
+225
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // @ts-expect-error - DrizzleClient.$client is not typed to have an `end` method, | |
| // but in practice it does (e.g. pg's Client does). | |
| await ensDbClient.ensDb.$client.end(); | |
| console.log("ENSDb client closed"); | |
| const anyClient = ensDbClient as any; | |
| try { | |
| const rawEnsDb = anyClient?.ensDb; | |
| const rawUnderlyingClient = rawEnsDb?.$client; | |
| const endFn = rawUnderlyingClient?.end; | |
| if (typeof endFn === "function") { | |
| await endFn.call(rawUnderlyingClient); | |
| console.log("ENSDb client closed"); | |
| } else { | |
| console.log("ENSDb client has no 'end' method; skipping close"); | |
| } | |
| } catch (closeErr) { | |
| console.log("Failed to close ENSDb client cleanly:", closeErr); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| console.log("Closing ENSDb client..."); | |
| // @ts-expect-error - DrizzleClient.$client is not typed to have an `end` method, | |
| // but in practice it does (e.g. pg's Client does). | |
| await ensDbClient.ensDb.$client.end(); | |
| console.log("ENSDb client closed"); | |
| log("Closing ENSDb client..."); | |
| // @ts-expect-error - DrizzleClient.$client is not typed to have an `end` method, | |
| // but in practice it does (e.g. pg's Client does). | |
| await ensDbClient.ensDb.$client.end(); | |
| log("ENSDb client closed"); |
Finally block uses console.log() instead of the standard log() function, causing inconsistent logging formatting
Uh oh!
There was an error while loading. Please reload this page.