Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Using IO or rescuing exceptions when setting a timeout

Aperta
#302 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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
Ambito
api, backend

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rubyjs/mini_racer

Tutte le issue di rubyjs/mini_racer

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.