Using IO or rescuing exceptions when setting a timeout
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, ruby
Direzione di ricerca
Start by reading stop_attached and def timeout(&blk) in MiniRacer, the two entry points named in the report. Reproduce the attached callback with a timeout, IO, and a rescued exception, then compare the reported termination errors; done means identifying why timeout handling changes the callback outcome and documenting or fixing the behavior.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello everyone :)
I've ran into a curious issue when setting a timeout at context creation. The underlying timeout detection doesn't seem to allow for rescue exceptions in attached methods, nor using IO.
Here is an example :
def download_base64(url)
data = URI.open(url)
data = Base64.encode64(data&.read || "")
{ data: data }
rescue => e
{ error: e.to_s }
end
js_context = MiniRacer::Context.new(timeout: 10)
js_context.attach('download64', proc { |url|
download_base64(url)
})
begin
result = js_context.call('download64', 'https://google.com/favicon.ico')
puts "RESULT: #{result}"
rescue => e
puts "ERROR: #{e}"
end
The code above ends up outputting:
ERROR: JavaScript was terminated (either by timeout or explicitly)
If I remove the rescue from the download_base64 ruby method, the output turns into :
ERROR: Terminated during callback
I have traced the error above to stop_attached inside MiniRacer.
If I remove the timeout, the result is a base64 encoded string of the Google's favicon.
I have disabled the timeout for now but would be very interesting to understand what goes on behind the scene. I have tried to go into the def timeout(&blk) method, and I am not sure why the current code there doesn't work, it doesn't seem to do anything you wouldn't expect it do it.
- Lingua principale
- JavaScript
- Stelle
- 628
- Fork
- 100
- Merge medio
- 1g 20h
- PR unite (30g)
- 2
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di rubyjs/mini_racer
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
rubyjs/mini_racer#449 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
rubyjs/mini_racer#450 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
rubyjs/mini_racer#448 ·
-
bug/crash platform: linux/x86
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
rubyjs/mini_racer#422 · 10 commenti ·
-
platform: darwin/x86
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
rubyjs/mini_racer#388 · 4 commenti ·
Tutte le issue di rubyjs/mini_racer
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
rescript-lang/rescript#8996 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Ministerstvoidey.ruApertacheck:passed logos:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
fossasia/visdom-dev#69 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
-
建议写成 1949-Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DeanChensj/jiangshan-map#133 ·
I maintainer di solito rispondono entro 1 giorno