Expected behavior
Editing fields should work as usual.
Actual behavior
Editing any field results in the following error:
Cannot read property ‘format’ of undefined
Failure Logs
We’ve tracked down the issue to the timezone
variable not being found in params
in the internal ResourceUpdater
(node_modules/forest-express-sequelize/dist/services/resource-updater.js
).
When logging this._params
line 33 of the file, this is what we see: { recordId: '[truncated by OP]' }
We do see the timezone
GET parameter in the logs URL:
PUT /forest/MyModel/[truncated by OP]?timezone=Europe%2FParis 500 100 - 46.201 ms
This causes the offsetClient
computation in the BaseOperatorDateParser
to crash, possibly due to a Babel issue.
Exact location of crash in node_modules/forest-express/dist/services/base-operator-date-parser.js
line 35:
var offsetClient = Number.parseInt((0, _momentTimezone["default"])().tz(options.timezone).format('Z'), 10);
The crash happens after .tz
returns undefined
. This may be unexpected behaviour caused by Babel as we’ve found that .tz
, when called via a simple require
instead of the interop layer, returns a proper Moment
object:
var momentTimezone = require('moment-timezone')
momentTimezone.tz(undefined) // returns a Moment object
var interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var momentTimezoneInterop = interopRequireDefault(require("moment-timezone"))
momentTimezoneInterop['default']().tz(undefined) // returns undefined
Context
Please provide any relevant information about your setup.
- Package Version: forest-express-sequelize 8.0.9, forest-express 9.1.1
- Express Version: 4.17.1
- Sequelize Version: 6.6.5
- Database Dialect: MSSQL
- Database Version: -
- Project Name: -
This does not happen in our development environment but only in the staging and production environments. The development environment runs on Windows machines, the staging and prod run on Docker (node:16
).
We have recently upgraded to V8.