-
Notifications
You must be signed in to change notification settings - Fork 983
Description
Bug Report
Serving static data with plugin restify.plugins.serveStatic alternating returns 405
Restify Version
6.3.4
Node.js Version
v8.9.0
Expected behaviour
Static resource request should be served with status 200
Actual behaviour
Sometimes static resource request will be served with status 405
Repro case
git clone https://github.com/s-a/restify-routes-start.gitcd restify-routes-startnpm installnpm start- Browse to http://localhost:8001 and open devtools.
This example request a static JSON file 3 times. In this case 2 of them returns with 405
Update:
I tried to take a look at the code but cannot identify what is going wrong here. The wrong exit point for my requests is here /lib/router.js#L581. Hard to understand because there are so many exit points in Router.prototype.find but if I understand correct the program should not reach this code area. So I think the main error occurs before matchURL where re parameter changes while runtime.
re.exec fails with /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\/?.*\b/gi
re.exec succeed with /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\/?.*\b/ which is the original regular expression i passed to .get function.
