Small server runtime modernization PR (if you want)

Hi folks,

This sunday I went down the rabbit hole of Meteor’s server runtime, bundle format, and boot sequence, an area I still felt weaker on and wanted to understand better because why not ? :man_shrugging:

After reading through the code, sketching a few diagrams, asking Claude way too many questions, and sanity-checking some ideas with ChatGPT, I ended up spotting a few places where the current server runtime still reflects older Node-era constraints, even though modern Node now gives us better native tools for some of these cases :+1:

So I’m starting a small PR series focused on a few very small, pragmatic cleanups in the current Node server runtime :smiling_imp: changes that seem useful on their own, with a good signal/risk ratio, and that should be easy to review independently :pray:

The goal is simple: make a few parts of the current runtime a bit more modern, a bit less fragile, and a bit easier to reason about.

First PRs

  1. Add sourceURL pragma to vm-evaluated server packages
    PR: Add sourceURL pragma to vm-evaluated server packages by dupontbertrand · Pull Request #14282 · meteor/meteor · GitHub
  2. Lazy-load cluster in webapp when UNIX_SOCKET_PATH is used
    PR: Lazy-load cluster in webapp when UNIX_SOCKET_PATH is used by dupontbertrand · Pull Request #14283 · meteor/meteor · GitHub

Validation so far

I validated both changes locally. Current results:

  • sourceURL pragma present in modified bundle
  • baseline and modified bundles boot and return HTTP 200
  • stack traces captured successfully in both bundles
  • stack trace attribution remained equivalent in my local check
  • UNIX_SOCKET_PATH still works
  • meteor run still boots correctly

I’ll use this thread for any broader discussion/questions about the overall direction, so the PRs can stay focused on the diffs themselves :blush:

Thanks!

8 Likes

Three more small ones in the same spirit — same approach: minimal diff, no behavioral change, easy to review.


PR #14302Replace hasOwnProperty.call() with Object.hasOwn()

Both webapp_server.js and boot.js define a manual helper:


const hasOwn = Object.prototype.hasOwnProperty;

// ...

if (hasOwn.call(obj, key)) { ... }

Object.hasOwn() is the standard replacement for this pattern, available since Node 16.9. Meteor requires Node 18.16+, so it’s safe to use unconditionally. This PR replaces all 11 call sites and removes both helper definitions.


PR #14303Replace url.parse() with WHATWG URL in stream_server.js

The WebSocket path rewriting code does a dynamic Npm.require('url') inside the request listener (on every request/upgrade event) and uses the legacy url.parse() / url.format() APIs. There was already a // TODO replace with url package comment on that line.

This replaces it with new URL(), which is a global since Node 10. Also modernizes the arguments capture into rest parameters while we’re there. Net result: fewer lines, no dynamic require on the hot path, resolves an existing TODO.


PR #14304Replace +new Date with Date.now() in boot.js

The debugger-attach polling loop uses +new Date and new Date - x for timing. Date.now() does the same thing but is more explicit and doesn’t create intermediate Date objects. Three occurrences, all in the same function.


Validation

Same as before — meteor create --blaze, boot, HTTP 200, no regressions. Each PR is independent and can be reviewed/merged in any order.

That brings the series to 5 PRs total:

  1. #14282 — sourceURL pragma

  2. #14283 — lazy-load cluster

  3. #14302 — Object.hasOwn()

  4. #14303 — WHATWG URL

  5. #14304 — Date.now()

All very small, all on devel, all CI-green.

2 Likes