Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

l10n error when accessing My Shots with scratch profile #3401

Closed
ianb opened this issue Aug 24, 2017 · 6 comments
Closed

l10n error when accessing My Shots with scratch profile #3401

ianb opened this issue Aug 24, 2017 · 6 comments
Assignees
Labels

Comments

@ianb
Copy link
Contributor

ianb commented Aug 24, 2017

To reproduce:

General error:
TypeError: Cannot read property 'map' of undefined

TypeError: Cannot read property 'map' of undefined
    at Object.exports.createModel (/Users/ianbicking/src/pageshot/build/server/pages/shotindex/model.js:32:18)
    at Object.exports.render (/Users/ianbicking/src/pageshot/build/server/reactrender.js:9:31)
    at _render (/Users/ianbicking/src/pageshot/build/server/pages/shotindex/server.js:30:17)
    at /Users/ianbicking/src/pageshot/build/server/pages/shotindex/server.js:13:5
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/route.js:137:13)
    at csrf (/Users/ianbicking/src/pageshot/node_modules/csurf/index.js:117:5)
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at /Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:275:10)
    at expressInit (/Users/ianbicking/src/pageshot/node_modules/express/lib/middleware/init.js:40:5)
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:317:13)
    at /Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:275:10)
    at query (/Users/ianbicking/src/pageshot/node_modules/express/lib/middleware/query.js:44:5)
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:317:13)
    at /Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:174:3)
    at EventEmitter.handle (/Users/ianbicking/src/pageshot/node_modules/express/lib/application.js:174:10)
    at mounted_app (/Users/ianbicking/src/pageshot/node_modules/express/lib/application.js:230:10)
    at Layer.handle [as handle_request] (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:317:13)
    at /Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:335:12)
    at next (/Users/ianbicking/src/pageshot/node_modules/express/lib/router/index.js:275:10)
    at /Users/ianbicking/src/pageshot/build/server/middleware/l10n.js:23:5
@jaredhirsch
Copy link
Member

This is pretty bizarre. The top line in the traceback indicates that a shots.map call inside the shotindex model fails because shots is undefined, yet that line is guarded by a check against undefinedness: if (shots !== undefined).

I can't repro this error, I either get the infinite refresh if I follow the described STR, or if I take a shot, then visit /shots, the page loads fine.

Regardless, I'll just switch the check to something array-specific, like if (shots && shots.length) { ... and we'll see if @ianb can still repro.

@jaredhirsch
Copy link
Member

I also don't get this error in the case where I create a scratch profile, create one shot, visit shots, then delete the one shot. I wind up with the "Go on, create some shots" view.

@jaredhirsch
Copy link
Member

@SoftVision-CosminMuntean Have you seen this error? Do you know of reliable STR?

@chenba
Copy link
Collaborator

chenba commented Aug 29, 2017

I was able to reproduce this with the steps given by @ianb. If you look at the server.js for shotindex, the first thing it does is check for !req.deviceId, then call _render() without any arguments when true. Fairly certain that's the cause.

ianb added a commit that referenced this issue Aug 29, 2017
Ensure that `shots` is an array before calling `shots.map()` (#3401)
@jaredhirsch
Copy link
Member

@ianb Can you verify that this is fixed? I still cant' repro locally

@ianb
Copy link
Contributor Author

ianb commented Sep 5, 2017

I've bumped into this in production and not dev, using the same steps, which I believe is because of the fix in 75df157

@ianb ianb closed this as completed Sep 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants