samyun / southwest-price-drop-bot

Bot that watches Southwest flights for price drops.
Other
74 stars 41 forks source link

Error rendering history graph #55

Closed ribordy closed 4 years ago

ribordy commented 4 years ago

My instance successfully fetched some new prices for flights last night, but I'm now unable to view any flight page (request hangs before the app crashes entirely). Stacktrace below, seems it's coming from the history graph component. I'll poke around at this tonight, but I wanted to surface this now in case anyone else was running into a similar problem.

2019-07-18T16:36:20.026194+00:00 app[web.1]: (node:23) UnhandledPromiseRejectionWarning: TypeError: Class constructor CoreMongooseArray cannot be invoked without 'new'
2019-07-18T16:36:20.026212+00:00 app[web.1]:     at initCloneArray (/app/node_modules/lodash.clonedeep/index.js:1235:22)
2019-07-18T16:36:20.026214+00:00 app[web.1]:     at baseClone (/app/node_modules/lodash.clonedeep/index.js:854:14)
2019-07-18T16:36:20.026216+00:00 app[web.1]:     at cloneDeep (/app/node_modules/lodash.clonedeep/index.js:1399:10)
2019-07-18T16:36:20.026220+00:00 app[web.1]:     at render (/app/lib/history-graph.js:16:16)
2019-07-18T16:36:20.026223+00:00 app[web.1]:     at /app/lib/apps/app.js:137:47
2019-07-18T16:36:20.026225+00:00 app[web.1]:     at processTicksAndRejections (internal/process/task_queues.js:85:5)
2019-07-18T16:36:20.026227+00:00 app[web.1]:     at emitUnhandledRejectionWarning (internal/process/promises.js:141:15)
2019-07-18T16:36:20.026229+00:00 app[web.1]:     at processPromiseRejections (internal/process/promises.js:202:23)
2019-07-18T16:36:20.026232+00:00 app[web.1]:     at processTicksAndRejections (internal/process/task_queues.js:86:32)
2019-07-18T16:36:20.026332+00:00 app[web.1]: (node:23) TypeError: Class constructor CoreMongooseArray cannot be invoked without 'new'
2019-07-18T16:36:20.026336+00:00 app[web.1]:     at initCloneArray (/app/node_modules/lodash.clonedeep/index.js:1235:22)
2019-07-18T16:36:20.026338+00:00 app[web.1]:     at baseClone (/app/node_modules/lodash.clonedeep/index.js:854:14)
2019-07-18T16:36:20.026340+00:00 app[web.1]:     at cloneDeep (/app/node_modules/lodash.clonedeep/index.js:1399:10)
2019-07-18T16:36:20.026342+00:00 app[web.1]:     at render (/app/lib/history-graph.js:16:16)
2019-07-18T16:36:20.026345+00:00 app[web.1]:     at /app/lib/apps/app.js:137:47
2019-07-18T16:36:20.026347+00:00 app[web.1]:     at processTicksAndRejections (internal/process/task_queues.js:85:5)

EDIT: Wanted to add in that the history graph portion that's failing hasn't changed in years, so my initial suspicion is that something changed in regards to the way we're storing and/or retrieving alerts.

brussrus commented 4 years ago

I believe I'm seeing the same issue. I can generate an initial alert, but when I go back to the web site to modify it I cannot. The page just hangs. I resorted to going into the DB table and modifying the record directly so I wouldn't keep getting alerted that the price was lower.

brussrus commented 4 years ago

So, I just figured out how to fix this. Super easy. Instead of requiring the older standalone lodash.clonedeep which was an exported version 4.5, just use the newer method that is inside the already included lodash. So edit your history-graph.js file and replace the single line: const cloneDeep = require('lodash.clonedeep');

with the following: const cloneDeep = require('lodash/clonedeep');

Since he's already including the entire lodash module (and a newer version), you don't need to use the standalone module. Easier than doing your Array.from changes.

Works like a charm! I'm now able to see the graph, and get to the edit functions.

ribordy commented 4 years ago

Good find. I'll amend my PR to include add an explicit dependency on lodash and replace that instance of cloneDeep.