npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@douglance/stdb-eslint-plugin

v1.0.0

Published

ESLint rules for SpacetimeDB V8 runtime pitfalls - catch serialization bugs at IDE level

Downloads

10

Readme

@spacetimedb/eslint-plugin

ESLint plugin that catches SpacetimeDB V8 runtime serialization bugs at IDE level, preventing runtime crashes before they reach production.

Installation

npm install --save-dev @spacetimedb/eslint-plugin

Usage

Add to your .eslintrc.js:

module.exports = {
  plugins: ['@spacetimedb'],
  extends: ['plugin:@spacetimedb/recommended'],
};

Or configure rules individually:

module.exports = {
  plugins: ['@spacetimedb'],
  rules: {
    '@spacetimedb/no-template-literals-in-reducer': 'error',
    '@spacetimedb/no-foreach-in-reducer': 'error',
    '@spacetimedb/no-filter-on-table-iter': 'warn',
    '@spacetimedb/no-insert-id-in-lifecycle-hooks': 'error',
  },
};

Rules

no-template-literals-in-reducer (error)

Problem: Template literals cause TypeError: r.charCodeAt is not a function due to V8 serialization bugs.

Before:

gameSchema.reducer('join_game', {}, (ctx) => {
  console.log(`Player ${ctx.sender} joined`); // ❌ RUNTIME CRASH
});

After:

gameSchema.reducer('join_game', {}, (ctx) => {
  const sender = String(ctx.sender);
  console.log("Player " + sender + " joined"); // ✅ WORKS
});

no-foreach-in-reducer (error)

Problem: forEach with closures causes silent serialization failures that break table operations.

Before:

gameSchema.reducer('update_all', {}, (ctx) => {
  lobbies.forEach(lobby => { // ❌ SERIALIZATION FAILURE
    ctx.db.Lobby.update(lobby);
  });
});

After:

gameSchema.reducer('update_all', {}, (ctx) => {
  for (let i = 0; i < lobbies.length; i++) { // ✅ WORKS
    const lobby = lobbies[i];
    ctx.db.Lobby.update(lobby);
  }
});

no-filter-on-table-iter (warning)

Problem: Calling .filter() on table iterators or indexed accessors causes runtime crashes.

Before:

const members = ctx.db.LobbyMembership.byLobby.filter([lobbyId]); // ❌ CRASH

After:

const members = [];
for (const m of ctx.db.LobbyMembership.iter()) {
  if (m.lobbyId === lobbyId) members.push(m); // ✅ WORKS
}

no-insert-id-in-lifecycle-hooks (error)

Problem: Using Entity.insert().id in clientConnected/clientDisconnected causes TypeError: Cannot read properties of undefined (reading '__identity__').

Before:

gameSchema.clientConnected((ctx) => {
  const entityId = ctx.db.Entity.insert({}).id; // ❌ CRASH
  ctx.db.Position.insert({ entity_id: entityId });
});

After (Option 1: Separate reducer):

gameSchema.clientConnected((ctx) => {
  // Don't spawn entities here
});

gameSchema.reducer('spawn_entity', {}, (ctx) => {
  const entityId = ctx.db.Entity.insert({}).id; // ✅ WORKS
  ctx.db.Position.insert({ entity_id: entityId });
});

After (Option 2: Scheduled reducer):

gameSchema.reducer('game_tick', ScheduledTickArgs, (ctx) => {
  const entityId = ctx.db.Entity.insert({}).id; // ✅ WORKS
  ctx.db.Position.insert({ entity_id: entityId });
});

Why This Plugin Exists

SpacetimeDB runs reducer code in a V8 JavaScript runtime with custom serialization. Certain JavaScript patterns that work perfectly in Node.js or browsers trigger serialization bugs in SpacetimeDB's runtime, causing:

  • TypeError: r.charCodeAt is not a function
  • TypeError: Cannot convert [object Object] to a BigInt
  • TypeError: Cannot read properties of undefined
  • Silent failures where operations appear to succeed but data never persists

These bugs are nearly impossible to debug because:

  1. Code looks correct and passes type checking
  2. Errors only occur at runtime after publishing to SpacetimeDB
  3. Error messages don't indicate the root cause
  4. No local development environment can reproduce them

This plugin brings these runtime failures into your IDE as red squiggly lines, making them impossible to commit.

Testing

npm test

License

MIT