- Track EOSE with a done flag so a healthy relay with no matching events returns immediately instead of waiting out the timeout - Restore the ensure around the client thread cleanup - Raise the metadata fetch client timeout to 60s to cover the worst-case sequential discovery on the server
This commit is contained in:
2 files changed
+12
-8
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
const REQUEST_TIMEOUT = 30000
|
||||
const REQUEST_TIMEOUT = 60000
|
||||
const REFRESH_ATTEMPTS = 5
|
||||
const REFRESH_DELAY = 2000
|
||||
const STEP_FOR_KIND = { 10002: "relays", 0: "profile", 10063: "blossom" }
|
||||
|
||||
@@ -11,6 +11,7 @@ module NostrManager
|
||||
def call
|
||||
filter, client, relay = @filter, @client, @relay
|
||||
event = nil
|
||||
done = false
|
||||
errored = false
|
||||
mutex = Mutex.new
|
||||
received_event = ConditionVariable.new
|
||||
@@ -39,6 +40,7 @@ module NostrManager
|
||||
end
|
||||
elsif msg && msg[0] == "EOSE"
|
||||
mutex.synchronize do
|
||||
done = true
|
||||
received_event.signal
|
||||
end
|
||||
end
|
||||
@@ -47,16 +49,18 @@ module NostrManager
|
||||
client.connect relay
|
||||
end
|
||||
|
||||
mutex.synchronize do
|
||||
received_event.wait(mutex, TIMEOUT) if event.nil? && !errored
|
||||
end
|
||||
begin
|
||||
mutex.synchronize do
|
||||
received_event.wait(mutex, TIMEOUT) if event.nil? && !done && !errored
|
||||
end
|
||||
|
||||
if event.nil? && !errored
|
||||
Rails.logger.debug "#{log_prefix} Timeout: No event received within #{TIMEOUT} seconds"
|
||||
if event.nil? && !done && !errored
|
||||
Rails.logger.debug "#{log_prefix} Timeout: No event received within #{TIMEOUT} seconds"
|
||||
end
|
||||
ensure
|
||||
thread.exit
|
||||
end
|
||||
|
||||
thread.exit
|
||||
|
||||
event
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user