Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'every')
at new Fieldset (fieldset.js:43:1)
at document.js:74:1
at Array.map (<anonymous>)
at Document._createFieldsets (document.js:73:1)
at new Document (document.js:60:1)
at get field [as field] (default.js:129:1)
at getPossibleMandatoryProxyValue (index.js:1383:1)
at _getProp (index.js:1448:1)
at reference.js:222:1
at reference.js:170:1
This is the crashing code (ember-form/lib/fieldset.js):
var _raw$form, _raw$answers;
let {
document,
raw
} = _ref,
args = _objectWithoutProperties(_ref, _excluded);
(true && !(document) && (0, _debug.assert)("`document` must be passed as an argument", document));
(true && !((raw === null || raw === void 0 ? void 0 : (_raw$form = raw.form) === null || _raw$form === void 0 ? void 0 : _raw$form.__typename) === "Form") && (0, _debug.assert)("A graphql form `raw.form` must be passed", (raw === null || raw === void 0 ? void 0 : (_raw$form = raw.form) === null || _raw$form === void 0 ? void 0 : _raw$form.__typename) === "Form"));
(true && !(_raw$answers.every(answer => /Answer$/.test(answer.__typename))) && (0, _debug.assert)("A collection of graphql answers `raw.answers` must be passed", raw === null || raw === void 0 ? void 0 : (_raw$answers = raw.answers) === null || _raw$answers === void 0 ? void 0 : _raw$answers.every(answer => /Answer$/.test(answer.__typename))));
Bizarrely _raw$answers gets initialised to undefined and then .every is run on it in the ternary operator. No assignment to it happens before that.
I have this issue where the form builder crashes at the point where it is rendering the default answer input (see the crash description below).
This appears due to a
babel-plugin-debug-macros
bug: https://github.com/ember-cli/babel-plugin-debug-macros/issues/89Fix
To work around the open issue in babel the assert shouldn't use optional chaining in
addon/lib/fieldset.js
:Crash description
Console log:
This is the crashing code (
ember-form/lib/fieldset.js
):Bizarrely
_raw$answers
gets initialised toundefined
and then.every
is run on it in the ternary operator. No assignment to it happens before that.