I'm more on the relay side of things, but I did write some scripts (mostly to clean crap out of my relays) and hit the same issue. Can you replace fetchEvents with subscribe? Subscrihe behaved much better for my use cases.
Discussion
Nope i canβt. I use subscribe a lot too, but in this specific case i need fetchEvents
Got it. fetchEvents is just a wrapper over subscribe with closeOnEose anyway (see https://github.com/nostr-dev-kit/ndk/blob/master/ndk/src/ndk/index.ts#L707-L712 ). Not the cleanest workaround, but if you don't want to go down to the subscribe level you can always wrap or copy and paste fetchEvents to your own "fetchEventsWithTimeout" function, e.g. you can use Promise.race between fetchEvents and a timeout promise that automatically rejects the promise after a certain amount of time.