WindmillWWindmill
Powered by
EggingtonE
Windmill•15mo ago•
1 reply
Eggington

error: Top-level await promise never resolved

I have a script using typescript deno that is querying a MongoDB atlas database. When either of the collection querying methods (.find or .findOne) take too long, windmill throws this error
error: Top-level await promise never resolved
    await run();
    ^
    at <anonymous> (file:///tmp/windmill/wk-default-e2b39e03fc37-DlTlU/01938d90-f94d-cd94-9e2a-95a351ab7870/wrapper.ts:29:5)
error: Top-level await promise never resolved
    await run();
    ^
    at <anonymous> (file:///tmp/windmill/wk-default-e2b39e03fc37-DlTlU/01938d90-f94d-cd94-9e2a-95a351ab7870/wrapper.ts:29:5)


I have already investigated storing my values in smaller documents and using .find() to query all of them or saving all as one document. Neither solves this issue, which brought me back to windmill. Also, i can successfully use these methods to query running a script locally on my machine.

Below is the code:
import { connectToIFSINTDatabase } from './mongodb_helpers.ts'

export async function main(key: string) {
  // the key should be a string formatted as such: yyyyMMdd-OH01 where OH is 2 digit state code and 01 is workstation number
  const client = await connectToIFSINTDatabase()
  try {
    const messagesCollection = client.database("IFSINT").collection("messages"); 
    const messages = await messagesCollection.find({debugKey: key}).toArray()
    console.log(messages)
    // const all_users = await users.find({ username: { $ne: null } }).toArray();
    return
  } catch (error) {
    console.error("Error:", error);
  } finally {
    await client.close();
  }
}
import { connectToIFSINTDatabase } from './mongodb_helpers.ts'

export async function main(key: string) {
  // the key should be a string formatted as such: yyyyMMdd-OH01 where OH is 2 digit state code and 01 is workstation number
  const client = await connectToIFSINTDatabase()
  try {
    const messagesCollection = client.database("IFSINT").collection("messages"); 
    const messages = await messagesCollection.find({debugKey: key}).toArray()
    console.log(messages)
    // const all_users = await users.find({ username: { $ne: null } }).toArray();
    return
  } catch (error) {
    console.error("Error:", error);
  } finally {
    await client.close();
  }
}
WindmillJoin
3,362Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Recent Announcements
henri-c

Weekly kenote to tell you about our latest updates https://discord.com/channels/930051556043276338/1278977038430240813 https://youtube.com/live/2dGd9TdT8xs?feature=share

henri-c · 4d ago

Pyra

### HTTP tracing (EE) Capture HTTP requests made by job scripts as observability spans Features: - View HTTP request traces (method, URL, status, timing) in the job details UI - Auto-instrumentation for Native TypeScript, MITM proxy for other languages - Integrates with external OpenTelemetry collectors changelog: https://www.windmill.dev/changelog/http-tracing docs: https://www.windmill.dev/docs/advanced/instance_settings#http-tracing Additionally jobs memory metrics are now fully OSS!

Pyra · 2w ago

henri-c

First keynote of the year here https://discord.com/channels/930051556043276338/1278977038430240813 🙂

henri-c · 4w ago

Similar Threads

ERROR: A script with same hash (...) already exists! (RESOLVED)
Chris @ Konnect3dCChris @ Konnect3d / help
2y ago
Failed to request tarball from API Bad RequestSql error (RESOLVED)
Chris @ Konnect3dCChris @ Konnect3d / help
2y ago
Output is wrapped in a promise
EntVlEEntVl / help
15mo ago
Unable to Deploy Flow from Admins to Prod Workspace (Row-Level Security Error)
skvochSskvoch / help
10mo ago