Skip to content

Conversation

@sgammon
Copy link
Member

@sgammon sgammon commented Jul 8, 2025

Ready for review Powered by Pull Request Badge

Summary

First pass at implementing Node's util module.

  • Node API: util #1203
    • callbackify
    • promisify
    • isArray
    • debuglog
    • deprecate
    • transferableAbort{Controller,Signal}
    • TextEncoder / TextDecoder constructors
    • MIMEType
    • MIMEParams
    • getSystemErrorName
    • getSystemErrorMap
    • inherits
    • format
      • Strings with %s
      • Strings with %i, %d, %f
      • Strings with object formatting (%j, %o, %O)
    • formatWithOptions
      • Basic support for colors
      • Enforcement of maxArrayItems
      • Enforcement of maxStringLength
      • Enforcement of depth note: ish
    • inspect
      • Booleans, Strings, Numbers
      • Dates, Instants, Durations
      • Host-side List, Set, Map
      • Guest-side [ ... ], { ... } (lists and sets)
    • types
      • isAnyArrayBuffer
      • isArrayBufferView
      • isArgumentsObject
      • isArrayBuffer
      • isAsyncFunction
      • isBigInt64Array
      • isBigIntObject
      • isBigUint64Array
      • isBooleanObject
      • isDate
      • isFloat16Array
      • isFloat32Array
      • isFloat64Array
      • isGeneratorFunction
      • isInt8Array
      • isInt16Array
      • isInt32Array
      • isMap
      • isNumberObject
      • isPromise
      • isRegExp
      • isSet
      • isSharedArrayBuffer
      • isStringObject
      • isSymbolObject
      • isTypedArray
      • isUint8Array
      • isUint8ClampedArray
      • isUint16Array
      • isUint32Array
      • isWeakMap
      • isWeakSet

@sgammon sgammon added this to the Release R18: Beta milestone Jul 8, 2025
@sgammon sgammon self-assigned this Jul 8, 2025
@sgammon sgammon added this to Elide Jul 8, 2025
@sgammon sgammon added feature Large PRs or issues with full-blown features 🚧 WIP Works-in-progress. Blocks merge lang:javascript Issues relating to JavaScript api:node Node API and stdlib labels Jul 8, 2025
@sgammon sgammon moved this to In Progress in Elide Jul 8, 2025
sgammon added 5 commits July 8, 2025 16:42
feat(node): implement `util.promisify`
feat(node): implement `util.callbackify`
feat(node): mount `TextEncoder` and `TextDecoder`
test(node): add initial tests for `util` module
chore: update `graalvm` api pins
chore: apply patch for `JSPromiseObject` use to `truffle-api`

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): implement debug logger facade + behavior
feat(cli): implement `--js:debug` flag support for js debug logging
test(cli): activation of `--js:debug` logging
chore: update serialized logging config
chore: update `graalvm` module pins

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): add `DeprecatedCallable` which warns on first use
feat(node): implement `util.deprecate` method
test(node): simple tests for `util.deprecate`

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): implement `transferableAbortController`
feat(node): implement `transferableAbortSignal`
test(node): simple tests for transferable abort signal/controller methods
chore: update `graalvm` module pins

Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
@codecov
Copy link

codecov bot commented Jul 8, 2025

Codecov Report

Attention: Patch coverage is 62.33522% with 400 lines in your changes missing coverage. Please review.

Project coverage is 41.04%. Comparing base (72abee6) to head (2a33c76).
Report is 18 commits behind head on main.

Files with missing lines Patch % Lines
...n/kotlin/elide/runtime/node/util/NodeTypechecks.kt 47.05% 21 Missing and 42 partials ⚠️
.../kotlin/elide/runtime/node/util/StringFormatter.kt 66.66% 39 Missing and 21 partials ⚠️
...c/main/kotlin/elide/runtime/node/util/MimeTypes.kt 43.18% 44 Missing and 6 partials ⚠️
.../kotlin/elide/runtime/node/util/ObjectInspector.kt 64.53% 37 Missing and 13 partials ⚠️
...rc/main/kotlin/elide/runtime/node/util/NodeUtil.kt 71.60% 33 Missing and 13 partials ⚠️
...n/kotlin/elide/runtime/node/util/InspectOptions.kt 39.18% 45 Missing ⚠️
...kotlin/elide/runtime/intrinsics/js/node/UtilAPI.kt 27.58% 18 Missing and 3 partials ⚠️
...ide/runtime/intrinsics/js/node/util/DebugLogger.kt 7.14% 13 Missing ⚠️
.../kotlin/elide/runtime/node/util/DebugLoggerImpl.kt 77.77% 4 Missing and 6 partials ⚠️
...in/kotlin/elide/runtime/intrinsics/js/JsPromise.kt 66.66% 5 Missing and 3 partials ⚠️
... and 9 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1527      +/-   ##
==========================================
+ Coverage   40.37%   41.04%   +0.67%     
==========================================
  Files         717      733      +16     
  Lines       33463    34525    +1062     
  Branches     4646     4862     +216     
==========================================
+ Hits        13511    14172     +661     
- Misses      18375    18663     +288     
- Partials     1577     1690     +113     
Flag Coverage Δ
jvm 41.04% <62.33%> (+0.67%) ⬆️
lib 41.04% <62.33%> (+0.67%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...time/gvm/intrinsics/BuildTimeIntrinsicsResolver.kt 100.00% <100.00%> (ø)
...lin/elide/runtime/intrinsics/js/AbortController.kt 100.00% <ø> (ø)
...ntime/intrinsics/js/node/util/InspectOptionsAPI.kt 100.00% <100.00%> (ø)
...m/internals/intrinsics/js/abort/AbortController.kt 95.83% <75.00%> (-4.17%) ⬇️
...kotlin/elide/runtime/node/util/InertDebugLogger.kt 50.00% <50.00%> (ø)
...e/gvm/internals/intrinsics/js/abort/AbortSignal.kt 82.29% <50.00%> (-2.16%) ⬇️
...lide/runtime/intrinsics/js/node/util/MIMEParams.kt 0.00% <0.00%> (ø)
...kotlin/elide/runtime/node/util/NodeSystemErrors.kt 97.32% <97.32%> (ø)
...kotlin/elide/tool/cli/cmd/repl/ToolShellCommand.kt 33.96% <0.00%> (-0.09%) ⬇️
...tlin/elide/runtime/node/util/DeprecatedCallable.kt 83.33% <83.33%> (ø)
... and 12 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 72abee6...2a33c76. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

feat(node): implement `util.MIMEType` class
feat(node): implement `util.MIMEParams` class
test(node): tests for MIME type parsing

Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon sgammon force-pushed the feat/node-util branch 3 times, most recently from ce3cf53 to fc11a17 Compare July 9, 2025 08:27
@sgammon sgammon linked an issue Jul 9, 2025 that may be closed by this pull request
@sgammon sgammon marked this pull request as ready for review July 9, 2025 18:33
@sgammon sgammon requested review from a team and Copilot July 9, 2025 18:33

This comment was marked as outdated.

@sgammon sgammon removed the 🚧 WIP Works-in-progress. Blocks merge label Jul 9, 2025
sgammon added 5 commits July 9, 2025 13:02
Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): implement `util.getSystemErrorName`
feat(node): implement `util.getSystemErrorMap`
test(node): tests for system error methods in `util`

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): most type checks on `util.types`
test(node): tests for `util.types`

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): add `InspectOptions` and impl
feat(node): add `util.inspect` for primitives
feat(node): add `util.inspect` for host-side complex types (pt 1)
feat(node): add `util.inspect` for guest-side complex types (pt 1)
test(node): tests for `util.inspect`

Signed-off-by: Sam Gammon <sam@elide.dev>
feat(node): implement primitive `util.format` support
chore(node): move object inspection to dedicated file
test(node): primitive `util.format` tests

Signed-off-by: Sam Gammon <sam@elide.dev>
sgammon added 2 commits July 9, 2025 13:02
Signed-off-by: Sam Gammon <sam@elide.dev>
Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon sgammon requested a review from Copilot July 9, 2025 20:05
@sgammon sgammon moved this from In Progress to Done in Elide Jul 9, 2025

This comment was marked as outdated.

Signed-off-by: Sam Gammon <sam@elide.dev>
@sgammon sgammon requested a review from Copilot July 9, 2025 20:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a first-pass implementation of Node’s util module on GraalVM, including the full host-side NodeUtil API, support for formatting and inspection (util.format, inspect, formatWithOptions), type-checking helpers (util.types), debug logging, deprecation wrappers, and MIME type utilities, alongside a comprehensive suite of Kotlin tests.

  • Introduces NodeUtil with callbackify/promisify, debuglog/deprecate, inspect/format, error name lookup, abort controllers, MIME types, and typechecks
  • Implements host-side formatting via StringFormatter and inspection via ObjectInspector with full InspectOptions support
  • Adds exhaustive tests in NodeUtilTest.kt and necessary test harness improvements (executeESM)

Reviewed Changes

Copilot reviewed 32 out of 34 changed files in this pull request and generated 2 comments.

File Description
packages/graalvm/src/main/kotlin/elide/runtime/node/util/NodeUtil.kt Core util module implementation (callbackify, inspect, etc.)
packages/graalvm/src/main/kotlin/elide/runtime/node/util/NodeTypechecks.kt util.types.* methods implemented
packages/graalvm/src/main/kotlin/elide/runtime/node/util/StringFormatter.kt Implements %-based formatting logic
packages/graalvm/src/test/kotlin/elide/runtime/node/NodeUtilTest.kt Comprehensive test suite covering all util APIs

@sgammon sgammon merged commit d6f2180 into main Jul 10, 2025
27 of 28 checks passed
@elidebot elidebot mentioned this pull request Jul 19, 2025
29 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:node Node API and stdlib feature Large PRs or issues with full-blown features lang:javascript Issues relating to JavaScript

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Node API: util

3 participants