cube
cube copied to clipboard
TypeConverting circular structure to JSON error when configuring two dataSources
Describe the bug I am configuring two dataSources - Mongo and Postgres - on my cubejs. When running any query on the Playground after configuration, the error message reads as below
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Timeout'
| property '_idlePrev' -> object with constructor 'TimersList'
--- property '_idleNext' closes the circle
at JSON.stringify (

To Reproduce Steps to reproduce the behavior:
- Edit cube.js to include two dataSources
- Open Playground.
- Select any measure and dimension and run the query. For now, I havent created any joins between Postgres tables and Mongo collections. I have defined a schema that only looks at a mongo collection.
- See error
Expected behavior
- If I remove multiple dataSources and use just 'default' - pointing to Mongo, the queries run fine.
- The error happens only when two dataSources are specified in cube.js
Screenshots If applicable, add screenshots to help explain your problem.
Minimally reproducible Cube Schema cube.js
const PostgresDriver = require('@cubejs-backend/postgres-driver');
const MongoBIDriver = require('@cubejs-backend/mongobi-driver');
module.exports = {
driverFactory: ({ dataSource }) => {
if (dataSource === 'entity') {
return new PostgresDriver({
database: 'pgdbname',
host: 'localhost',
user: 'postgres',
password: 'password',
port: '5432',
});
}
if (dataSource === 'default'){
return new MongoBIDriver({
database: 'test',
host: 'localhost',
user: 'some_mongo_user',
password: 'password',
port: '3307',
});
}
throw new Error('dataSource is undefined');
},
};
cube(`Partner`, {
sql: `SELECT * FROM partner`,
preAggregations: {
// Pre-Aggregations definitions go here
// Learn more here: https://cube.dev/docs/caching/pre-aggregations/getting-started
},
joins: {
},
measures: {
count: {
type: `count`,
drillMembers: [id, partner_type]
},
},
dimensions: {
id: {
sql: `id`,
type: `number`,
primaryKey: true,
},
partner_type: {
sql: `partner_type`,
type: `string`
},
},
dataSource: `entity`
});
cube(`Load`, {
sql: `SELECT * FROM test.load`,
measures: {
count: {
type: `count`,
drillMembers: [category]
},
},
dimensions: {
id: {
sql: `_id`,
type: `string`,
primaryKey: true,
},
category: {
sql: `category`,
type: `string`
},
},
dataSource: `default`
});
Version: 0.30.37
@smoorthyk Please use new driverFactory
format that returns DriverConfig
object https://cube.dev/docs/config#driver-factory