SShortSingh.
Back to feed

Cursor pagination can silently drop rows due to JS Date precision loss

0
·6 views

A common Node.js approach to keyset (cursor) pagination can quietly skip rows, sometimes ending pagination after the first page. The problem stems from JavaScript Date objects holding millisecond precision while Postgres timestamps store microseconds. Rows inserted in the same millisecond can then be mishandled when the cursor is compared. The suggested fix is to keep the cursor as the exact database text value, such as created_at::text, so the comparison stays exact. Other options include using millisecond-precision timestamps with an id tiebreaker, or paginating on id alone when ids are monotonic. The author recommends testing by walking every page against a real database to confirm no rows are missing or repeated.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

macOS Git Trusts Compromised eMudhra Certificates, Here's How to Remove Them

Apple's bundled git on macOS can still trust compromised eMudhra certificates, which may let automated builds accept revoked identities. The guide explains that macOS git reads certificates from the system keychain rather than OpenSSL defaults, so revoked certificates remain valid if they stay in the keychain. It provides commands to detect eMudhra certificates, delete them by SHA-256 fingerprint, and confirm the trust chain is clean. It also recommends adding a CI check that fails builds if the certificates reappear, and notes checking user keychains, Homebrew git configuration, and cached TLS sessions.

0
ProgrammingDEV Community ·

Building a Node.js Voice Assistant with ElevenLabs Text-to-Speech

A DEV Community tutorial walks developers through creating a command-line voice assistant using Node.js and the ElevenLabs API. The assistant accepts typed queries, forwards them to an LLM such as OpenAI's ChatGPT for a reply, converts that reply into speech, and plays the audio back. The guide explains the prerequisites, including Node.js 18 or later, API keys, and optionally ffmpeg for audio playback. It also covers project setup, storing credentials in a .env file, and a lightweight text-to-speech wrapper that saves the output as an MP3. The article notes that ElevenLabs also supports voice cloning using a short audio sample.

0
ProgrammingDEV Community ·

Build an n8n Watchdog That Alerts When a Workflow Never Runs

n8n's Error Trigger only catches failed runs, so a workflow that never starts, due to a dead cron, changed webhook URL, or deactivation after an edit, goes unnoticed. The article proposes a dead-man's switch: a separate watchdog workflow that runs hourly and checks the monitored workflow's execution history via the n8n Public API. It classifies the workflow as overdue if no runs exist or the latest run is older than a configurable threshold, and sends a Gmail alert only in that case. Setup requires an n8n API key, the target workflow ID, a threshold set to roughly twice its expected interval, and Gmail OAuth2 credentials. The author reports testing the detection logic on a local n8n instance but says email delivery still needs to be confirmed by running a test alert.

0
ProgrammingDEV Community ·

FiftyOne 1.19 Adds Native MCAP Playback for Synced Drone Sensor Recordings

FiftyOne 1.19 can now open MCAP log files directly, combining camera, LiDAR, GPS, IMU, and log streams on one shared timeline without requiring a ROS installation. The author demonstrates this with a UAV flight through a Virginia forest lasting about four and a half minutes, which produced nearly 600,000 messages across 31 channels. Because MCAP is a self-describing container, each recording stays decodable even after the software that wrote it is gone. Users point a sample's filepath at a .mcap file, and the App automatically treats it as multimodal data, rendering image, 3D, map, plot, log, and message tiles that all move together during playback. Channels without a built-in decoder still appear as raw, collapsible record trees, so no data in the file goes unseen.