Baoyuantop commented on issue #13041:
URL: https://github.com/apache/apisix/issues/13041#issuecomment-3976021119

   Hi @luuvanloia4, the header_filter phase is designed for high-performance 
stream processing, and unlike the access or rewrite phases, it does not have a 
built-in pcall wrapper in the core plugin runner. An unhandled exception in 
this phase is considered a critical error and will terminate the request 
processing.
   
   The responsibility for robust error handling within a filter phase lies with 
the plugin developer. The recommended approach is to wrap your logic inside 
pcall within your plugin's header_filter function. This allows you to catch any 
exceptions, log them for debugging, and prevent the request from crashing.
   
   ```lua
   function _M.header_filter(conf, ctx)
       local ok, err = pcall(function()
           -- Your original header_filter logic goes here.
       end)
   
       if not ok then
           core.log.error("Error in my_custom_plugin header_filter: ", err)
       end
   end
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to