Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set Timezone on connection using SYSTEM timezone #52

Closed
grgrssll-dev opened this issue May 14, 2019 · 7 comments
Closed

Cannot set Timezone on connection using SYSTEM timezone #52

grgrssll-dev opened this issue May 14, 2019 · 7 comments

Comments

@grgrssll-dev
Copy link

grgrssll-dev commented May 14, 2019

lib version v2.0.5
Maria v10.3.13
Connection via Sequelize v5

{ 
  Error: (conn=55, no: 45036, SQLState: 08S01) Automatic timezone setting fails. Server timezone 'PDT' does't have a corresponding IANA timezone. Option timezone must be set according to server timezone
    at Object.module.exports.createError (/some/directory/node_modules/mariadb/lib/misc/errors.js:56:10)
    at query.then.res (/some/directory/node_modules/mariadb/lib/connection.js:730:20)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
     fatal: true,
     errno: 45036,
     sqlState: '08S01',
     code: 'ER_WRONG_AUTO_TIMEZONE'
}

When I try to connect I am getting this error, I'm not sure why because my coworker has the same settings and it is working for him. Connecting through Sequelize v5.

The error points to this file: /node_modules/mariadb/lib/connection.js:730:20 where I see this query: SELECT @@system_time_zone stz, @@time_zone tz The output of which reads:

stz tz
PDT SYSTEM

however the next part of the code does a lookup in moment which is expecting an IANA timezone string like 'America/Los_Angeles' but it is getting fed the argument 'PDT' so it returns null...

As seen in the moment docs here:
https://momentjs.com/timezone/docs/#/zone-object/abbr/

const serverTimezone = res[0].tz === 'SYSTEM' ? res[0].stz : res[0].tz;
const serverZone = moment.tz.zone(serverTimezone); 
// serverTimezone is 'PDT' here not 'America/Los_Angeles' and serverZone is null as a result...

I've tried setting my timezone in mariadb to the IANA America/Los_Angeles but it says it's invalid...

How can I get this working?

@grgrssll-dev
Copy link
Author

It seems to work if I use 'US/Pacific' instead of 'America/Los_Angeles' in the options.timezone

@knoxcard
Copy link
Contributor

I know this might sound stupid, but have you tried...

yarn add https://github.com/MariaDB/mariadb-connector-nodejs.git
or
npm install https://github.com/MariaDB/mariadb-connector-nodejs.git

@rusher
Copy link
Collaborator

rusher commented May 16, 2019

Can you indicate sequelize and moment-timezone versions in package-lock.json ?
I fail to understand how 'US/Pacific' instead of 'America/Los_Angeles' would change anything with the latest version.

@grgrssll-dev
Copy link
Author

grgrssll-dev commented May 17, 2019

Sorry for the delay.
The mariadb-connector-nodejs did not help...

sequelize: 5.8.6
moment-timezone: 0.5.25

The sequelize constructor options for dialectOptions are

// Doesn't work
dialectOptions: {
    timezone: 'America/Los_Angeles',
    // also doesn't work if no timezone option presented
},
// throws: ER_WRONG_AUTO_TIMEZONE
// Does work
dialectOptions: {
    timezone: 'US/Pacific',
},

@knoxcard
Copy link
Contributor

Everything good? Close issue?

@rusher
Copy link
Collaborator

rusher commented May 20, 2019

ok, found the issue. Using timezone exactly corresponding to client current timezone might cause automatic retrieval of server timezone.
This is corrected with 9fc5d23 that will be in next release

@rusher rusher closed this as completed May 20, 2019
@grgrssll-dev
Copy link
Author

Fix verified working for me. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants