Skip to content

fix(padrino): avoid ActiveSupport's try - #635

Merged
ElMassimo merged 1 commit into
ElMassimo:mainfrom
osbre:fix-padrino-preload-try
Oct 16, 2026
Merged

ElMassimo merged 1 commit into
ElMassimo:mainfrom
osbre:fix-padrino-preload-try

Conversation

@osbre

@osbre osbre commented Oct 13, 2026

Copy link
Copy Markdown

Description 📖

This pull request fixes a NoMethodError in vite_padrino when an entrypoint imports a shared chunk.

Background 📜

This was happening because vite_preload_tag calls try(:request), and try comes from ActiveSupport, which Padrino doesn't load. Vite emits a modulepreload tag whenever two entrypoints import the same module, so any such app crashes when rendering vite_javascript_tag:

NoMethodError - undefined method 'try' for an instance of App

The Fix 🔨

By changing the try calls to plain respond_to? checks. Early hints are still sent when the request supports them.

Screenshots 📷

N/A. Tested with a generated Padrino app with two entrypoints sharing a module, after vite build: before, a 500 error; after, a 200 with the <link rel="modulepreload"> tag rendered.

nesquena added a commit to padrino/padrino-framework that referenced this pull request Oct 14, 2026
Adds `--script=vite` (vite_padrino) for `padrino g project` and `padrino g component`, with the ActiveSupport Object#try workaround until ElMassimo/vite_ruby#635 ships. Salvage of #2334.

Co-authored-by: Ostap Brehin <osbre@protonmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@ElMassimo

Copy link
Copy Markdown
Owner

Thanks Ostap!

@ElMassimo
ElMassimo merged commit ab4540f into ElMassimo:main Oct 16, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants