From 75f26b475cd68be2616bc1d8ea915db28e023e31 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 16 Jun 2026 08:09:31 +0200 Subject: [PATCH] ResumableParser: Reset err_info on EOS errors Fix: https://github.com/ruby/json/issues/1008 I'm unfortunately unable to turn the reproduction script into a test case there, I don't understand what is causing `err_info` to be re-raised in the repro that doesn't work in test-unit. ```ruby require 'json' parser = JSON::ResumableParser.new({}) ['{"message": "hello ', 'world"}', '[1,2]'].each do |chunk| parser << chunk begin while parser.parse p parser.value end rescue JSON::ParserError => e p e parser.clear end end ``` --- ext/json/ext/parser/parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c index e722a1a7..fa66d084 100644 --- a/ext/json/ext/parser/parser.c +++ b/ext/json/ext/parser/parser.c @@ -2412,6 +2412,7 @@ static VALUE cResumableParser_parse(VALUE self) complete = false; if (RTEST(rb_ivar_get(rb_errinfo(), rb_intern("@eos")))) { complete = false; // is an EOS error + rb_set_errinfo(Qnil); } else { rb_jump_tag(status); // reraise }