scene.toJSON() producing undefined value somewhere in the object

scene.toJSON is producing an object which apparently contains an undefined value. I am working with automerge to handle real-time versioning in my scene, and automerge does not accept undefined values (null is ok) so it is throwing the error as shown in [1] below. However, when I observe the full scope of the JSON as logged to the browser console [2], no such undefined value exists. The code to produce this problem is in [3] below.

This appears to be related to what was documented here

[1]

Uncaught TypeError: Unsupported type of value: undefined
    at Context.getValueDescription (context.js:53:13)
    at Context.setValue (context.js:302:32)
    at Context.createNestedObjects (context.js:268:33)
    at Context.setValue (context.js:299:19)
    at Context.insertListItems (context.js:400:33)
    at Context.createNestedObjects (context.js:258:12)
    at Context.setValue (context.js:299:19)
    at Context.createNestedObjects (context.js:268:33)
    at Context.setValue (context.js:299:19)
    at eval (context.js:342:33)

[2]

{
    "metadata": {
        "version": 4.5,
        "type": "Object",
        "generator": "Object3D.toJSON"
    },
    "geometries": [
        {
            "uuid": "80c62362-ea58-4e39-9f34-19140a402428",
            "type": "BufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            0,
                            0,
                            0,
                            -45,
                            -1
                        ],
                        "normalized": false
                    }
                },
                "boundingSphere": {
                    "center": [
                        0,
                        -22.5,
                        -0.5
                    ],
                    "radius": 22.5055548698538
                }
            }
        },
        {
            "uuid": "8aec5271-1118-43c1-ba8e-bacd2aed8399",
            "type": "BufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            0,
                            0,
                            0,
                            -45,
                            -1
                        ],
                        "normalized": false
                    }
                },
                "boundingSphere": {
                    "center": [
                        0,
                        -22.5,
                        -0.5
                    ],
                    "radius": 22.5055548698538
                }
            }
        },
        {
            "uuid": "6ac8c5ce-b495-425a-902b-251c3b405c5b",
            "type": "BoxGeometry",
            "width": 1,
            "height": 2,
            "depth": 0.3,
            "widthSegments": 1,
            "heightSegments": 1,
            "depthSegments": 1
        },
        {
            "uuid": "e6199c67-834f-42c2-9285-722c265fb77d",
            "type": "CylinderGeometry",
            "radiusTop": 0.2,
            "radiusBottom": 0.2,
            "height": 0.1,
            "radialSegments": 50,
            "heightSegments": 1,
            "openEnded": false,
            "thetaStart": 0,
            "thetaLength": 6.283185307179586
        },
        {
            "uuid": "d43893ec-8d81-4e2b-81ab-df4791776fa5",
            "type": "InstancedBufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            0,
                            1,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            0
                        ],
                        "normalized": false
                    },
                    "normal": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1
                        ],
                        "normalized": false
                    },
                    "uv": {
                        "itemSize": 2,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0
                        ],
                        "normalized": false
                    }
                },
                "index": {
                    "type": "Uint16Array",
                    "array": [
                        0,
                        2,
                        1,
                        2,
                        3,
                        1,
                        4,
                        6,
                        5,
                        6,
                        7,
                        5
                    ]
                },
                "groups": [
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 0
                    },
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 1
                    }
                ],
                "boundingSphere": {
                    "center": [
                        0,
                        0,
                        0
                    ],
                    "radius": -1
                }
            },
            "instanceCount": null,
            "isInstancedBufferGeometry": true
        },
        {
            "uuid": "1042b1fe-f0f7-404d-8d5e-4194368fbf42",
            "type": "InstancedBufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            0,
                            1,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            0
                        ],
                        "normalized": false
                    },
                    "normal": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1
                        ],
                        "normalized": false
                    },
                    "uv": {
                        "itemSize": 2,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0
                        ],
                        "normalized": false
                    }
                },
                "index": {
                    "type": "Uint16Array",
                    "array": [
                        0,
                        2,
                        1,
                        2,
                        3,
                        1,
                        4,
                        6,
                        5,
                        6,
                        7,
                        5
                    ]
                },
                "groups": [
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 0
                    },
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 1
                    }
                ],
                "boundingSphere": {
                    "center": [
                        0,
                        0,
                        0
                    ],
                    "radius": -1
                }
            },
            "instanceCount": null,
            "isInstancedBufferGeometry": true
        },
        {
            "uuid": "118d0349-6105-406f-ad8e-6731ac1b4588",
            "type": "InstancedBufferGeometry",
            "data": {
                "attributes": {
                    "position": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            0,
                            1,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            0
                        ],
                        "normalized": false
                    },
                    "normal": {
                        "itemSize": 3,
                        "type": "Float32Array",
                        "array": [
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1,
                            0,
                            0,
                            -1
                        ],
                        "normalized": false
                    },
                    "uv": {
                        "itemSize": 2,
                        "type": "Float32Array",
                        "array": [
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1,
                            1,
                            1,
                            0,
                            0,
                            1,
                            0
                        ],
                        "normalized": false
                    }
                },
                "index": {
                    "type": "Uint16Array",
                    "array": [
                        0,
                        2,
                        1,
                        2,
                        3,
                        1,
                        4,
                        6,
                        5,
                        6,
                        7,
                        5
                    ]
                },
                "groups": [
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 0
                    },
                    {
                        "start": 0,
                        "count": null,
                        "materialIndex": 1
                    }
                ],
                "boundingSphere": {
                    "center": [
                        0,
                        0,
                        0
                    ],
                    "radius": -1
                }
            },
            "instanceCount": null,
            "isInstancedBufferGeometry": true
        }
    ],
    "materials": [
        {
            "uuid": "303f4ca4-6198-4bbd-8d53-02def5764018",
            "type": "LineBasicMaterial",
            "color": 16777215,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680,
            "linewidth": 20
        },
        {
            "uuid": "3f9173f4-75f6-4f57-8841-4d677db7558f",
            "type": "LineBasicMaterial",
            "color": 16777215,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680,
            "linewidth": 20
        },
        {
            "uuid": "8201d885-616f-42ea-bcd6-9511597ab2d6",
            "type": "MeshStandardMaterial",
            "color": 11674146,
            "roughness": 1,
            "metalness": 0,
            "emissive": 0,
            "envMapIntensity": 1,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680,
            "flatShading": true
        },
        {
            "uuid": "5a7d7bf0-b6c2-437f-a8e2-af9b9aba4ba9",
            "type": "MeshStandardMaterial",
            "color": 3100495,
            "roughness": 1,
            "metalness": 0,
            "emissive": 0,
            "envMapIntensity": 1,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680,
            "flatShading": true
        },
        {
            "uuid": "94F7F9E9-6E9F-4711-B5F7-B143991E2F1E",
            "type": "MeshBasicMaterial",
            "color": 16777215,
            "reflectivity": 1,
            "refractionRatio": 0.98,
            "shadowSide": 2,
            "side": 2,
            "transparent": true,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680
        },
        {
            "uuid": "C4D00A8C-5862-4879-87BA-19B1E875623C",
            "type": "MeshBasicMaterial",
            "color": 16777215,
            "reflectivity": 1,
            "refractionRatio": 0.98,
            "shadowSide": 2,
            "side": 2,
            "transparent": true,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680
        },
        {
            "uuid": "ac314811-69ad-4973-9659-fe895c4e73d4",
            "type": "MeshStandardMaterial",
            "color": 8900331,
            "roughness": 1,
            "metalness": 0,
            "emissive": 0,
            "envMapIntensity": 1,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680,
            "flatShading": true
        },
        {
            "uuid": "8C2F198C-EEEE-4830-9785-9930D24786E9",
            "type": "MeshBasicMaterial",
            "color": 16777215,
            "reflectivity": 1,
            "refractionRatio": 0.98,
            "shadowSide": 2,
            "side": 2,
            "transparent": true,
            "depthFunc": 3,
            "depthTest": true,
            "depthWrite": true,
            "colorWrite": true,
            "stencilWrite": false,
            "stencilWriteMask": 255,
            "stencilFunc": 519,
            "stencilRef": 0,
            "stencilFuncMask": 255,
            "stencilFail": 7680,
            "stencilZFail": 7680,
            "stencilZPass": 7680
        }
    ],
    "object": {
        "uuid": "57a9b6dc-ce24-41c7-814a-c81b03e35e5e",
        "type": "Scene",
        "layers": 1,
        "matrix": [
            1,
            0,
            0,
            0,
            0,
            1,
            0,
            0,
            0,
            0,
            1,
            0,
            0,
            0,
            0,
            1
        ],
        "background": 0,
        "children": [
            {
                "uuid": "49c158c9-a86f-4607-8eb5-1e69a5701c3c",
                "type": "Group",
                "visible": false,
                "layers": 1,
                "matrix": [
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1
                ],
                "matrixAutoUpdate": false,
                "children": [
                    {
                        "uuid": "9819b199-3180-43bd-8fcf-c78c11b7ffb8",
                        "type": "Object3D",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1
                        ]
                    },
                    {
                        "uuid": "b16b481f-22c3-4d96-a971-705db8419d17",
                        "type": "Line",
                        "name": "xrControllerRaycastBeam",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            100,
                            0,
                            0,
                            0,
                            0,
                            1
                        ],
                        "geometry": "80c62362-ea58-4e39-9f34-19140a402428",
                        "material": "303f4ca4-6198-4bbd-8d53-02def5764018"
                    }
                ]
            },
            {
                "uuid": "67494bbe-0472-4cfc-839e-cc60850d635f",
                "type": "Group",
                "visible": false,
                "layers": 1,
                "matrix": [
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1
                ],
                "matrixAutoUpdate": false,
                "children": [
                    {
                        "uuid": "ab867c6a-164a-4a3e-9a8e-aa19d03197cf",
                        "type": "Object3D",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1
                        ]
                    },
                    {
                        "uuid": "ed2dae1e-1aba-469c-b96d-e07fcfb12104",
                        "type": "Line",
                        "name": "xrControllerRaycastBeam",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            100,
                            0,
                            0,
                            0,
                            0,
                            1
                        ],
                        "geometry": "8aec5271-1118-43c1-ba8e-bacd2aed8399",
                        "material": "3f9173f4-75f6-4f57-8841-4d677db7558f"
                    }
                ]
            },
            {
                "uuid": "72a5476f-aad3-4675-9d6c-e875716729b9",
                "type": "HemisphereLight",
                "layers": 1,
                "matrix": [
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    1,
                    0,
                    1
                ],
                "color": 16777215,
                "intensity": 3,
                "groundColor": 3100495
            },
            {
                "uuid": "d2b60ea5-b2ac-4945-ba7d-327dea920b4d",
                "type": "DirectionalLight",
                "layers": 1,
                "matrix": [
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    10,
                    10,
                    10,
                    1
                ],
                "color": 16777215,
                "intensity": 8,
                "shadow": {
                    "camera": {
                        "uuid": "c8c9cfa2-0576-4702-ada9-22160df49e12",
                        "type": "OrthographicCamera",
                        "layers": 1,
                        "zoom": 1,
                        "left": -5,
                        "right": 5,
                        "top": 5,
                        "bottom": -5,
                        "near": 0.5,
                        "far": 500
                    }
                }
            },
            {
                "uuid": "8628de47-6aab-47e0-9fdd-8c68080f3d0c",
                "type": "Group",
                "name": "abs",
                "layers": 1,
                "matrix": [
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    -0.42697290231878493,
                    1.4580426916803302,
                    -10.312003535833327,
                    1
                ],
                "children": [
                    {
                        "uuid": "0094bc39-c3b6-408c-a49f-9707b1db7453",
                        "type": "Mesh",
                        "name": "panel_abs_0094bc39-c3b6-408c-a49f-9707b1db7453",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            1.4,
                            0,
                            1
                        ],
                        "geometry": "6ac8c5ce-b495-425a-902b-251c3b405c5b",
                        "material": "8201d885-616f-42ea-bcd6-9511597ab2d6"
                    },
                    {
                        "uuid": "7f4919eb-7d07-4a06-93e4-9387018bb201",
                        "type": "Mesh",
                        "name": "outlet_abs_7f4919eb-7d07-4a06-93e4-9387018bb201",
                        "layers": 1,
                        "matrix": [
                            0.5403023058681398,
                            0.841289028647364,
                            -0.01749824423037888,
                            0,
                            1.1102230246251565e-16,
                            0.020794827803092497,
                            0.999783764189357,
                            0,
                            0.8414709848078965,
                            -0.540185473161038,
                            0.011235493412141695,
                            0,
                            0,
                            1,
                            0.2,
                            1
                        ],
                        "geometry": "e6199c67-834f-42c2-9285-722c265fb77d",
                        "material": "5a7d7bf0-b6c2-437f-a8e2-af9b9aba4ba9"
                    },
                    {
                        "uuid": "57214949-4ed2-4fcb-bd28-e4bd7b6af24b",
                        "type": "Mesh",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            -0.3,
                            0.8,
                            0.2,
                            1
                        ],
                        "geometry": "d43893ec-8d81-4e2b-81ab-df4791776fa5",
                        "material": "94F7F9E9-6E9F-4711-B5F7-B143991E2F1E"
                    },
                    {
                        "uuid": "62b62ee7-58d2-4789-98c1-bd8207c49d08",
                        "type": "Mesh",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            2.3,
                            0.2,
                            1
                        ],
                        "geometry": "1042b1fe-f0f7-404d-8d5e-4194368fbf42",
                        "material": "C4D00A8C-5862-4879-87BA-19B1E875623C"
                    },
                    {
                        "uuid": "164a707d-a715-4cb6-b70b-5e57eb2e5a97",
                        "type": "Mesh",
                        "name": "inlet_value_164a707d-a715-4cb6-b70b-5e57eb2e5a97",
                        "layers": 1,
                        "matrix": [
                            0.5403023058681398,
                            0.841289028647364,
                            -0.01749824423037888,
                            0,
                            1.1102230246251565e-16,
                            0.020794827803092497,
                            0.999783764189357,
                            0,
                            0.8414709848078965,
                            -0.540185473161038,
                            0.011235493412141695,
                            0,
                            -0.5,
                            1.8,
                            0.2,
                            1
                        ],
                        "geometry": "e6199c67-834f-42c2-9285-722c265fb77d",
                        "material": "ac314811-69ad-4973-9659-fe895c4e73d4"
                    },
                    {
                        "uuid": "a0cc9de9-cb52-4c04-b17c-7eb5fee57e4e",
                        "type": "Mesh",
                        "layers": 1,
                        "matrix": [
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                            -0.5,
                            1.6,
                            0.2,
                            1
                        ],
                        "geometry": "118d0349-6105-406f-ad8e-6731ac1b4588",
                        "material": "8C2F198C-EEEE-4830-9785-9930D24786E9"
                    }
                ]
            }
        ]
    }
}

[3]

scene.updateMatrixWorld()
let sceneJSON = scene.toJSON()
console.log(sceneJSON)
doc1 = Automerge.change(doc1, 'update state', doc => {
    doc.three = sceneJSON
})