This is a minimal reproduction repository for a Meteor bug: using defineMutationMethods: false in a Mongo.Collection constructor together with aldeed:collection2 causes a startup crash in Meteor 3.4.1. It is not a production app — it exists solely to trigger and demonstrate the error.
- Meteor 3.4.1 (with Rspack bundler via
@meteorjs/rspack) - React 18.2 on the client
- MongoDB via Meteor's
mongopackage - Key packages:
aldeed:collection2@4.1.5,aldeed:simple-schema@1.13.1
| Command | What it does |
|---|---|
npm start |
meteor run — starts the app in dev mode |
npm test |
meteor test --once --driver-package meteortesting:mocha — runs tests once |
npm run test-app |
TEST_WATCH=1 meteor test --full-app — runs full-app tests with watch |
npm run visualize |
Starts with bundle visualizer |
The test runner is Mocha (via meteortesting:mocha). Tests live in tests/main.js. Test module is configured in package.json at meteor.testModule.
imports/
api/
links.js # MongoDB collection definition (THE BUG TRIGGER)
ui/
App.jsx # Root React component
Counter.jsx # Simple state counter example
Header.jsx # App header with SVG logo
Info.jsx # Subscribes to "links" publication, renders list
styles.css # All app styles
meteor-logo.svg # Imported as React component via @svgr/webpack
client/
main.jsx # Client entry: mounts React app
main.html # HTML entry: <head> and body with #react-target
main.css # (minimal, mostly unused)
server/
main.js # Server entry: seeds data, publishes "links", defines methods
tests/
main.js # Mocha tests
rspack.config.js # Rspack config
.swcrc # SWC transform config (React automatic JSX runtime)
imports/api/links.jscreates a collection withdefineMutationMethods: false- It applies a SimpleSchema via
attachSchema() - On startup,
aldeed:collection2callscollection.deny()which internally callsaddValidatorin theallow-denypackage addValidatoriterates over mutation method names (insert, update, remove, upsert) — but sincedefineMutationMethods: false, these methods areundefined- Result:
TypeError: Cannot read properties of undefined (reading 'insert')
import { Mongo } from 'meteor/mongo';
import SimpleSchema from 'meteor/aldeed:simple-schema';
import 'meteor/aldeed:collection2/static';
export const LinksCollection = new Mongo.Collection('links', { defineMutationMethods: false });
const schema = new SimpleSchema({});
LinksCollection.attachSchema(schema);await LinksCollection.insertAsync({ title, url, createdAt: new Date() });
await LinksCollection.find().countAsync();import { useFind, useSubscribe } from "meteor/react-meteor-data";
const isLoading = useSubscribe("links");
const links = useFind(() => LinksCollection.find());Meteor.startup(async () => { ... });
Meteor.publish("links", function () { ... });
Meteor.methods({ about() { ... } });meteor/aldeed:collection2/staticmust be imported separately (not just the package) for theattachSchemamethod to be available — this is acollection2v4 pattern.- No JSX transform config in rspack.config.js: the automatic JSX runtime is configured via
.swcrc("runtime": "automatic"), not via rspack's@rspack/plugin-react-refreshconfig. This means you don't needimport React from 'react'. - Entry points are declared in
package.jsonundermeteor.mainModule(not inrspack.config.js). - SVG imports resolve as React components via
@svgr/webpackrule inrspack.config.js. - The
private/andpublic/directories exist but are empty — they're standard Meteor scaffolding. - The
tests/main.jsusesMeteor.isClient/Meteor.isServerglobals directly (no imports needed — Meteor provides them). - The expected behavior (once the bug is fixed) is that
defineMutationMethods: falseshould preventallow-denyfrom trying to register mutation hooks.
client/main.csshas only apadding: 10pxrule — effectively unused. All real styles are inimports/ui/styles.css.