Skip to content

Commit 29b77ee

Browse files
committed
Prevent Bootsnap::LoadPathCache::FallbackScan from polluting exception cause
1 parent 530fdb1 commit 29b77ee

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

lib/bootsnap/load_path_cache/core_ext/kernel_require.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ def require(path)
3838
rescue Bootsnap::LoadPathCache::ReturnFalse
3939
false
4040
rescue Bootsnap::LoadPathCache::FallbackScan
41-
require_with_bootsnap_lfi(path)
41+
fallback = true
42+
ensure
43+
if fallback
44+
require_with_bootsnap_lfi(path)
45+
end
4246
end
4347

4448
alias_method(:require_relative_without_bootsnap, :require_relative)
@@ -67,7 +71,11 @@ def load(path, wrap = false)
6771
rescue Bootsnap::LoadPathCache::ReturnFalse
6872
false
6973
rescue Bootsnap::LoadPathCache::FallbackScan
70-
load_without_bootsnap(path, wrap)
74+
fallback = true
75+
ensure
76+
if fallback
77+
load_without_bootsnap(path, wrap)
78+
end
7179
end
7280
end
7381

@@ -88,6 +96,10 @@ def autoload(const, path)
8896
rescue Bootsnap::LoadPathCache::ReturnFalse
8997
false
9098
rescue Bootsnap::LoadPathCache::FallbackScan
91-
autoload_without_bootsnap(const, path)
99+
fallback = true
100+
ensure
101+
if fallback
102+
autoload_without_bootsnap(const, path)
103+
end
92104
end
93105
end

0 commit comments

Comments
 (0)