Skip to content

fix: remove silent try-catch in StartSessionMiddleware::after()#306

Merged
usernane merged 1 commit intomainfrom
dev
Apr 29, 2026
Merged

fix: remove silent try-catch in StartSessionMiddleware::after()#306
usernane merged 1 commit intomainfrom
dev

Conversation

@usernane
Copy link
Copy Markdown
Member

Summary

Remove the empty catch (Error $exc) block in StartSessionMiddleware::after() that silently swallowed all errors, including the static call bug from #297.

Motivation

The empty catch block made bugs invisible — no logging, no propagation. The static call to Response::addHeader() (fixed in #297) was hidden by this for the entire lifetime of the middleware. Errors in middleware should propagate so they can be diagnosed. Fixes #298.

Changes

  • Removed try/catch (Error $exc) wrapper from StartSessionMiddleware::after()
  • Removed unused use Error import

How to Test / Verify

  • Any error in after() will now propagate instead of being silently ignored
  • Existing test suite passes (672 tests, all non-DB tests green)

Breaking Changes and Migration Steps

None

Checklist

  • I reviewed my own diff before requesting review
  • My commits follow Conventional Commits
  • The title of the pull request follows Conventional Commits
  • I added/updated tests (or explained why not)
  • I updated docs (if needed)
  • I ran lint/cs-fixer (if applicable)
  • I considered backward compatibility
  • I considered security

Related issues

Closes #298

The empty catch(Error) block silently swallowed all errors, hiding
the static call bug fixed in #297. Errors in middleware should
propagate rather than be silently ignored.

Fixes #298
@usernane usernane merged commit fd44360 into main Apr 29, 2026
9 checks passed
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.89%. Comparing base (907984c) to head (9c5c3b6).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...ri/Framework/Middleware/StartSessionMiddleware.php 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #306      +/-   ##
============================================
+ Coverage     74.84%   74.89%   +0.04%     
+ Complexity     2974     2973       -1     
============================================
  Files            97       97              
  Lines          9509     9508       -1     
============================================
+ Hits           7117     7121       +4     
+ Misses         2392     2387       -5     
Flag Coverage Δ
php-8.1 76.21% <0.00%> (?)
php-8.2 76.16% <0.00%> (+<0.01%) ⬆️
php-8.3 74.96% <0.00%> (+<0.01%) ⬆️
php-8.4 74.96% <0.00%> (+<0.01%) ⬆️
php-8.5 74.86% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link
Copy Markdown

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.

bug: StartSessionMiddleware silently swallows errors in after() method

1 participant