Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Using IO or rescuing exceptions when setting a timeout

Đang mở
#302 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript, ruby
Lĩnh vực
api, backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
JavaScript
Star
628
Fork
100
Merge trung bình
1 ngày 20 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rubyjs/mini_racer

Tất cả issue của rubyjs/mini_racer

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.