Skip to content

.get does not identify valid route request after it returned correct response #1581

@s-a

Description

@s-a

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.git
  • cd restify-routes-start
  • npm install
  • npm 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

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions