loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Anomaly in router.stack sorting

Open blackvirus18 opened this issue 11 years ago • 7 comments

Hi Team,

I am experiencing an anomaly in the way stable sort is working on the router.stack object in server-app.js. On two different linux boxes I am getting different results. Find below the logs after sorting has been applied on router.stack object.

VM-Ware 1

[ { handle: { [Function: query] __NR_original: [Function: query] }, name: 'query', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined, phase: { builtin: true } }, { handle: { [Function: expressInit] __NR_original: [Function: expressInit] }, name: 'expressInit', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined, phase: { builtin: true } }, { handle: { [Function: favicon] __NR_original: [Function: favicon] }, name: 'favicon', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined }, { handle: { [Function: compression] __NR_original: [Function: compression] }, name: 'compression', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined }, { handle: { [Function] __NR_original: [Function] }, name: '', params: undefined, path: undefined, keys: [], regexp: /^/status/?(?=/|$)/i, route: undefined }, { handle: { [Function: serveStatic] __NR_original: [Function: serveStatic] }, name: 'serveStatic', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined }, { handle: { [Function: raiseUrlNotFoundError] __NR_original: [Function: raiseUrlNotFoundError] }, name: 'raiseUrlNotFoundError', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined }, { handle: { [Function: mounted_app] __NR_original: [Function: mounted_app] }, name: 'mounted_app', params: undefined, path: undefined, keys: [], regexp: /^/random-string/?(?=/|$)/i, route: undefined }, { handle: { [Function: restApiHandler] __NR_original: [Function: restApiHandler] }, name: 'restApiHandler', params: undefined, path: undefined, keys: [], regexp: /^/api/?(?=/|$)/i, route: undefined }, { handle: { [Function: router] __NR_original: [Object] }, name: 'router', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined }, { handle: [Function: sentinel], name: 'sentinel', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined, phase: 'final' }, { handle: { [Function: errorHandler] __NR_original: [Function: errorHandler] }, name: 'errorHandler', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'final:after' } ]


VM-Ware 2 [ { handle: [Function: query], name: 'query', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined, phase: { builtin: true } }, { handle: [Function: expressInit], name: 'expressInit', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined, phase: { builtin: true } }, { handle: [Function: favicon], name: 'favicon', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'initial:before' }, { handle: [Function: compression], name: 'compression', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'initial' }, { handle: [Function: mounted_app], name: 'mounted_app', params: undefined, path: undefined, keys: [], regexp: /^/random-string/?(?=/|$)/i, route: undefined }, { handle: [Function: restApiHandler], name: 'restApiHandler', params: undefined, path: undefined, keys: [], regexp: /^/api/?(?=/|$)/i, route: undefined }, { handle: { [Function: router] params: {}, _params: [], caseSensitive: undefined, mergeParams: undefined, strict: undefined, stack: [Object] }, name: 'router', params: undefined, path: undefined, keys: [], regexp: { /^/?(?=/|$)/i fast_slash: true }, route: undefined }, {* handle: [Function], name: '', params: undefined, path: undefined, keys: [], regexp: /^/status/?(?=/|$)/i, route: undefined, phase: 'routes'* }, { handle: [Function: serveStatic], name: 'serveStatic', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'files' }, { handle: [Function: raiseUrlNotFoundError], name: 'raiseUrlNotFoundError', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'final' }, { handle: [Function: errorHandler], name: 'errorHandler', params: undefined, path: undefined, keys: [], regexp: /(?:)/i, route: undefined, phase: 'final:after' } ]

I have highlighted the object which is causing this anomaly on VM- Ware 1 this object is coming before and on VM-Ware 2 this is coming after mounting the app because of which my api requests are being treated as static requests.

Let me know If more information is required.

blackvirus18 avatar Feb 19 '15 06:02 blackvirus18

I noticed that the phase property is missing for a few routes on VM-Ware1.

raymondfeng avatar Feb 19 '15 07:02 raymondfeng

Yes, Raymond that does seem to be the root cause but the point is that with the same codebase and and same middleware config files phase property is coming on VM-Ware 2 but not on VM-Ware 1 and this is causing a lot of problems for us.

blackvirus18 avatar Feb 19 '15 10:02 blackvirus18

Can you make sure both installations have the exact same versions of dependencies? Can you try to zip up the app on VM-Ware2 and unzip it to VM-Ware1.

For clean npm install, you can do the following too:

1. npm cache clean
2. cd my-app
3. rm -f node_modules
4. npm install

raymondfeng avatar Feb 19 '15 17:02 raymondfeng

Yes Raymond I already did that but still facing the same issue.

blackvirus18 avatar Feb 20 '15 02:02 blackvirus18

@blackvirus18 Can you please simplify your application to the point where you have a minimal example that reproduces the issues and that you can share with us? Without that, it's impossible for us to help you.

bajtos avatar Feb 23 '15 17:02 bajtos

Hi @blackvirus18 Is that issue still persisting? Thanks.

loay avatar Feb 23 '16 16:02 loay

hello,

closing this issue. If you are still running into problems, feel free to leave a comment and I will reopen the issue. Thanks

loay avatar Mar 23 '16 17:03 loay