For the last day I researched a mysterious issue in which a moment-timezone
feature would not work under particular, seemingly arbitrary circumstances. I discovered that the runtime version of my moment-timezone
library was changing at some point from version 0.5.17 to 0.5.13.
Before adding more details, is this a node.js
issue or a moment-timezone
issue?
The specific problem with moment-timezone
I ended up resolving using yarn selective-version-resolutions, but if this is a actually a node.js
issue, I'm thinking more extreme measures are called for (yarn install --flat?).
I don't know which dependency was causing the version to change at runtime, but this was the relevant section from my yarn.lock
file before adding the resolutions
section:
moment-timezone@0.5.17:
version "0.5.17"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.17.tgz#3c8fef32051d84c3af174d91dc52977dcb0ad7e5"
dependencies:
moment ">= 2.9.0"
moment-timezone@^0.5.0, moment-timezone@^0.5.4, moment-timezone@~0.5.5:
version "0.5.13"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.13.tgz#99ce5c7d827262eb0f1f702044177f60745d7b90"
dependencies:
moment ">= 2.9.0"
As you can see, my direct dependency was on version 0.5.17, but the dependency of my other modules was getting resolved to version 0.5.13. But I don't understand how at some point my dependency was getting resolved to 0.5.13.
To check the moment-timezone
version I simply used moment.tz.version
. That means that in my production code, the following code printed 0.5.17 until at some point suddenly printing 0.5.13:
const moment = require('moment-timezone');
console.log(`moment.tz.version: ${moment.tz.version}`);
One last detail: the moment-timezone function that was breaking when the version changed to 0.5.13 was the optional flag on the moment.tz
function added in version 0.5.14, in this code:
moment(utcDateTime, format).clone().tz(timezone, true)
Can anyone explain how this is possible? I hope it's a moment-timezone bug and not a node.js bug...