From 7c5f3866cd6d44aeb2e5ff5eed8d8d42c86e8f4a Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Thu, 30 Jul 2020 20:54:16 -0700 Subject: [PATCH] Prevent Bootsnap::LoadPathCache::FallbackScan from polluting exception cause --- .../load_path_cache/core_ext/kernel_require.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb b/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb index 7fbcc258..6050e806 100644 --- a/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb +++ b/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb @@ -38,7 +38,11 @@ def require(path) rescue Bootsnap::LoadPathCache::ReturnFalse false rescue Bootsnap::LoadPathCache::FallbackScan - require_with_bootsnap_lfi(path) + fallback = true + ensure + if fallback + require_with_bootsnap_lfi(path) + end end alias_method(:require_relative_without_bootsnap, :require_relative) @@ -67,7 +71,11 @@ def load(path, wrap = false) rescue Bootsnap::LoadPathCache::ReturnFalse false rescue Bootsnap::LoadPathCache::FallbackScan - load_without_bootsnap(path, wrap) + fallback = true + ensure + if fallback + load_without_bootsnap(path, wrap) + end end end @@ -88,6 +96,10 @@ def autoload(const, path) rescue Bootsnap::LoadPathCache::ReturnFalse false rescue Bootsnap::LoadPathCache::FallbackScan - autoload_without_bootsnap(const, path) + fallback = true + ensure + if fallback + autoload_without_bootsnap(const, path) + end end end