Middleware Load Order Shift in RailwayJS v2.1.0 Breaks Custom Plugin Initialization
20K reputation · 30 Aug 2020, 07:15 UTC
Middleware Load Order Shift in RailwayJS v2.1.0
When upgrading an application from RailwayJS v2.0.x to v2.1.0, the internal middleware registration was refactored to a centralized registry, altering the sequence in which third‑party plugins are invoked. Plugins that previously ran before core request parsers now execute after them, which can lead to missing request body data or failed authentication for plugins that depend on early access to the raw request.
The goal is to determine how to adapt existing plugins so they continue to function correctly after the upgrade while preserving compatibility with earlier RailwayJS releases.
- What steps should be taken to move plugin initialization to the new
afterMiddlewarehook without breaking support for v2.0.x? - How can developers verify that their plugins now execute after the core request parsers in a v2.1.0 environment?
- Is there a recommended pattern for version‑conditional plugin loading that maintains backward compatibility across the v2.0.x → v2.1.0 boundary?