Skip to content

fix(app): validate render() callback and preserve mountpath on multiple mounts - #7355

Closed
webdevdot wants to merge 1 commit into
expressjs:masterfrom
webdevdot:fix/render-callback-validation
Closed

fix(app): validate render() callback and preserve mountpath on multiple mounts#7355
webdevdot wants to merge 1 commit into
expressjs:masterfrom
webdevdot:fix/render-callback-validation

Conversation

@webdevdot

Copy link
Copy Markdown

Summary

  • Bug fail with text/plain #15 (lib/application.js): app.render() called without a callback crashes with a cryptic TypeError: done is not a function deep inside the rendering pipeline. This PR adds an early guard that throws a clear TypeError('app.render() requires a callback function') before any rendering starts.

  • Bug Session support #16 (lib/application.js): When a sub-app is mounted at multiple paths via app.use(['/a', '/b'], subApp), the fns.forEach loop overwrote fn.mountpath on each iteration, leaving only the last path. The fix accumulates paths into an array when the same sub-app is registered more than once.

Test plan

  • app.render('view') with no callback throws TypeError: app.render() requires a callback function
  • app.render('view', fn) still works (callback as second arg)
  • app.render('view', opts, fn) still works (normal usage)
  • Sub-app mounted at single path: mountpath is a string (unchanged behavior)
  • Sub-app mounted at two paths: mountpath is an array containing both paths
  • Existing test suite passes

🤖 Generated with Claude Code

…le mounts
Fixes two issues in application.js:
- app.render() now throws a clear TypeError when callback is missing or not a function
- app.mountpath is stored as an array when a sub-app is mounted at multiple paths
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@krzysdz

This comment was marked as off-topic.

@krzysdzkrzysdz closed this Jul 4, 2026
@krzysdzkrzysdz reopened this Jul 4, 2026
@krzysdz

Copy link
Copy Markdown
Contributor

Sorry, wrong tab

@webdevdot
webdevdot deleted the fix/render-callback-validation branch July 5, 2026 05:16
Sign up for freeto 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.

3 participants

@webdevdot@krzysdz@webcloudkey-projects