[GH-ISSUE #69] (esm) TypeError: Cannot read properties of undefined (reading 'uid') #23

Closed
opened 2026-05-23 08:38:44 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @donl on GitHub (Jan 8, 2023).
Original GitHub issue: https://github.com/appy-one/acebase-server/issues/69

I don't think I was doing anything special code-wise... Just poking around on the client while not being signed in. Doesn't seem to happen 100% repeatably.

file:///app/node_modules/acebase-server/dist/esm/middleware/user.js:28
            req.user = env.authCache.get(tokenDetails.uid);
                                                      ^

TypeError: Cannot read properties of undefined (reading 'uid')
    at file:///app/node_modules/acebase-server/dist/esm/middleware/user.js:28:55
    at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13)
    at /app/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12)
    at next (/app/node_modules/express/lib/router/index.js:280:10)
    at file:///app/node_modules/acebase-server/dist/esm/middleware/cache.js:7:9
    at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13)
    at /app/node_modules/express/lib/router/index.js:286:9
    at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12)
    at next (/app/node_modules/express/lib/router/index.js:280:10)
    at file:///app/node_modules/acebase-server/dist/esm/middleware/cors.js:41:9
    at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13)
    at /app/node_modules/express/lib/router/index.js:286:9

Node.js v18.11.0
Originally created by @donl on GitHub (Jan 8, 2023). Original GitHub issue: https://github.com/appy-one/acebase-server/issues/69 I don't think I was doing anything special code-wise... Just poking around on the client while not being signed in. Doesn't seem to happen 100% repeatably. ``` file:///app/node_modules/acebase-server/dist/esm/middleware/user.js:28 req.user = env.authCache.get(tokenDetails.uid); ^ TypeError: Cannot read properties of undefined (reading 'uid') at file:///app/node_modules/acebase-server/dist/esm/middleware/user.js:28:55 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13) at /app/node_modules/express/lib/router/index.js:286:9 at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12) at next (/app/node_modules/express/lib/router/index.js:280:10) at file:///app/node_modules/acebase-server/dist/esm/middleware/cache.js:7:9 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13) at /app/node_modules/express/lib/router/index.js:286:9 at Function.process_params (/app/node_modules/express/lib/router/index.js:346:12) at next (/app/node_modules/express/lib/router/index.js:280:10) at file:///app/node_modules/acebase-server/dist/esm/middleware/cors.js:41:9 at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/app/node_modules/express/lib/router/index.js:328:13) at /app/node_modules/express/lib/router/index.js:286:9 Node.js v18.11.0 ```
Author
Owner

@appy-one commented on GitHub (Jan 8, 2023):

Thanks @donl I'll take a look

<!-- gh-comment-id:1374878841 --> @appy-one commented on GitHub (Jan 8, 2023): Thanks @donl I'll take a look
Author
Owner

@appy-one commented on GitHub (Jan 8, 2023):

@donl it appears the issue is caused by a client sending a request with an invalid user token. The function parsing the token doesn't throw on unexpected input at https://github.com/appy-one/acebase-server/blob/master/src/shared/tokens.ts#L35

I'll fix this tomorrow!

<!-- gh-comment-id:1374881553 --> @appy-one commented on GitHub (Jan 8, 2023): @donl it appears the issue is caused by a client sending a request with an invalid user token. The function parsing the token doesn't throw on unexpected input at https://github.com/appy-one/acebase-server/blob/master/src/shared/tokens.ts#L35 I'll fix this tomorrow!
Author
Owner

@appy-one commented on GitHub (Jan 9, 2023):

I published the fix in v1.16.2, thanks for reporting @donl!

<!-- gh-comment-id:1375304735 --> @appy-one commented on GitHub (Jan 9, 2023): I published the fix in v1.16.2, thanks for reporting @donl!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase-server#23
No description provided.