Unhandled rejection TypeError: Cannot read property 'raw' of undefined
Closed this issue · 5 comments
Hello, first of all thank you for this awesome library!
My setup looks super simple with better-queue 3.8.10
and better-queue-sql 1.0.3
:
const Queue = require("better-queue");
const SQLStore = require('better-queue-sql');
const store = new SQLStore({
type: "sql",
dialect: "postgres",
host: DB_HOST,
port: DB_PORT,
username: DB_USER,
password: DB_PASS,
dbname: DB_NAME
});
const q = new Queue(handler, { store });
and i get the following error when trying to run it:
Unhandled rejection TypeError: Cannot read property 'raw' of undefined
at /Users/t/Development/queue-test/node_modules/better-queue-sql/index.js:64:23
I noticed that the callback for self.adapter.connect
gets called twice
- first time it gets called
adapter.knex
is defined - second time it gets called
adater.knex
is undefined, which causes the error
but it is only called once here, so I am a bit confused as to what is happening and why this strange behavior.
Any help or guidance would be really appreciated, thank you!
I think the issue may be related to not passing in tableName. I would try this instead:
const Queue = require("better-queue");
const q = new Queue(handler, {
store: {
type: 'sql',
dialect: 'postgres',
host: DB_HOST
port: DB_PORT,
username: DB_USER,
password: DB_PASS,
dbname: DB_NAME,
tableName: SOME_TABLE_NAME
}
});
Also don't forget to npm i pg
if you haven't already
That's it! Thank you!
I guess I was confused with the documentation thinking that postgres
was supported "out of the box," but when I initially tried this setup it was complaining that better-queue-
was missing, making me think that on top of installing better-queue-sql
I also needed to instantiate it then pass it as an option to Queue
.
Thank you once again @jknielse
@jknielse I see this is using the knex
to communicate with a postgres
database... in my code, I am using sequelize
as my main database driver... now i am seeing the following issue
Unhandled rejection error: tuple concurrently updated
at Connection.parseE (/Users/t/Development/node-api/node_modules/pg/lib/connection.js:554:11)
Would you happen to know if there is some sort of conflict that might be happening because of two separate connections to the same database?
I am not seeing an option in better-queue
to pass a connection instance instead of relying on knex
, so I was hoping to fork this adapter and have it accept that option and possibly change it sequelize
for all db communication - just not sure if this is what would fix it though...
Thanks!
Ooof, now that's a good question. I can't see any reason why you shouldn't be able to have both off the top of my head, but I'm not entirely sure. Is this happening when the store first connects, or is it blowing up later on?
it's happening when the store first connects, I am new to postgres
so the error message doesn't really make sense to me, because nothing else would be affecting the tasks
table other than the Queue
's store
this only happens when i choose postgres
as my store for better-queue
, so could be my main driver and this trying to do the same thing at the same time...
thanks anyway, I might just try rewriting it using sequelize
and sharing a connection and I'll see how it goes...