dalperin / remix-redis-session Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Redis expects the expires value to be an integer, however the expiresToSeconds
function returns values with a decimal value. As such, we get errors like this:
ReplyError: ERR value is not an integer or out of range
at parseError (C:\Source\__rp\payments-web\node_modules\redis-parser\lib\parser.js:179:12)
at parseType (C:\Source\__rp\payments-web\node_modules\redis-parser\lib\parser.js:302:14) {
command: {
name: 'set',
args: [
'KEY GOES HERE',
'{ DATA GOES HERE }',
'EX',
'1199.999' <-- This is the problem argument
]
}
}
I believe the fix is to simply wrap the return with Math.round
.
Hi! ๐
Firstly, thanks for your work on this project! ๐
When I tried setting a maxAge
that is sufficiently large, Redis complains that the expiry duration needs to be in [integer] seconds. I believe the problem is due to the use of floating point numbers. This patch fixed it for me, so it'll be great if you can apply this or similar to the code.
diff --git a/node_modules/remix-redis-session/dist/index.js b/node_modules/remix-redis-session/dist/index.js
index eefa741..a2b73d4 100644
--- a/node_modules/remix-redis-session/dist/index.js
+++ b/node_modules/remix-redis-session/dist/index.js
@@ -25,7 +25,7 @@ const expiresToSeconds = (expires) => {
const now = new Date();
const expiresDate = new Date(expires);
const secondsDelta = (expiresDate.getTime() - now.getTime()) / 1000;
- return secondsDelta < 0 ? 0 : secondsDelta;
+ return secondsDelta < 0 ? 0 : Math.round(secondsDelta);
};
function createRedisSessionStorage({ cookie, options }) {
let redis;
This issue body was partially generated by patch-package.
I was looking for an equivalent to express-session and connect-redis for Remix and remix-auth. Is that what you're aiming for? If so, would you share a working example?
I tried replacing the createCookieSessionStorage
call with createRedisSessionStorage
and that doesn't seem to be enough. I'm getting the following error:
/home/xxx/yyy/node_modules/remix-redis-session/dist/index.js:40
return (0, sessions_1.createSessionStorage)({
^
TypeError: (0 , sessions_1.createSessionStorage) is not a function
at createRedisSessionStorage (/home/xxx/yyy/node_modules/remix-redis-session/dist/index.js:40:48)
at Object.<anonymous> (/home/xxx/yyy/src/remix/app/auth/session.server.ts:9:29)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.