Skip to content

Instantly share code, notes, and snippets.

View justinvdm's full-sized avatar

Justin van der Merwe justinvdm

View GitHub Profile
@justinvdm
justinvdm / 2026-03-10-useSyncedState-websocket-constraints.md
Last active June 16, 2026 15:36
useSyncedState WebSocket constraints report

useSyncedState WebSocket constraints: deploy disconnects and hibernation cost

Summary

useSyncedState in RedwoodSDK currently depends on capnweb for its WebSocket transport. This creates two related constraints for production apps:

  1. Every deploy drops active WebSocket connections, because Cloudflare restarts Durable Objects on deploy. This is a platform-level behavior, not a bug in our code.
  2. Without the WebSocket Hibernation API, open connections keep Durable Objects active and billing wall-clock time even when idle. Whether this matters depends on the app's scale and usage pattern.

capnweb is not currently compatible with the Hibernation API, and the maintainer has indicated it is a large project with no near-term timeline. So we cannot fix both constraints by changing a flag. We need to choose between client-side reconnection on the current architecture, reimplementing the server on the Hibernation API, or documenting the limitations clearly.

@justinvdm
justinvdm / 2026-03-23-active-record-conversion-audit.md
Last active March 24, 2026 13:04
Active Record Conversion Audit & Phased Rollout Plan

Active Record Conversion Audit

Task Narrative

We need a comprehensive, up-to-date checklist of all code that still needs refactoring to use the Active Record pattern. An existing conversion plan lives at apps/web/src/models/active-record-conversion.md (created 2026-03-02). Our job is to verify whether that plan is still current, identify any gaps (new tables, new files), and produce a single authoritative checklist suitable for handing off to Kindling.

Synthesized Context

  • Active Record library: apps/web/src/lib/active-record/ (base Record, Collection, Relation classes)
  • Secure layer: apps/web/src/models/base/secure-record.ts (adds SecureModel + SecureCollection with auto-scoping, permissions, FK ownership validation)
@justinvdm
justinvdm / ad
Last active November 1, 2025 06:31
#!/bin/bash
set -euo pipefail
# A script to commit with an AI-generated message and push.
#
# Usage:
# ad
#
# Environment Variables:
# NO_AI: If set to "true", it will use a fallback commit message
const http = require('http');
const markup = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>rarily rar rar</title>
<script defer src="/head.js"></script>
// !!! NOTE !!!
// This is *not* meant to be a comparison to show which library is
// universally faster. In fact, it is quite likely that faker and
// chance have functions that perform better than the equivalents in
// fictional. The 'seed each' benchmarks below are probably also
// misuse of faker and chance. The intention of these benchmarks was
// to investigate and show why seeding as a way of mapping
// identifiers to generated values isn't viable, and why hashing is a
// promising solution
const Benchmark = require("benchmark");
const Benchmark = require("benchmark");
displayIntro()
const N = 1000;
const A = 'a'
const B = 'b'
const C = 'c'
const diff = (() => {
const toString = Function.prototype.toString;
const objectString = toString.call(Object);
return function diff(a, b, opts) {
opts = {
printShallow: false,
...opts,
};
const diff = (() => {
const toString = Function.prototype.toString;
const objectString = toString.call(Object);
return function diff(a, b, opts) {
opts = {
printShallow: false,
...opts,
};
function slowOp(factor) {
const n = 999999 * factor;
let i = -1;
while (++i < n) {
Math.pow(23, i % 3);
}
}
const http = require("http");
const CSS_DELAY = 5000;
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">