Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cloudflare/workerd
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b879eb9e87be1d315b9a107730d506dd5c1f9090
Choose a base ref
...
head repository: cloudflare/workerd
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 55e0408a3762cd1b1e86ffd80579fd20b7c1c5ba
Choose a head ref

Commits on Nov 20, 2024

  1. Copy the full SHA
    903c284 View commit details
  2. Copy the full SHA
    09ac5bf View commit details

Commits on Dec 2, 2024

  1. Fix test error and lint

    morgan9e committed Dec 2, 2024
    Copy the full SHA
    dfc7963 View commit details
  2. Copy the full SHA
    5b8942c View commit details
  3. Add missing api::url::URLSearchParams in Body::Initializer.

    Co-authored-by: James M Snell <jsnell@cloudflare.com>
    Signed-off-by: Jianyong Chen <baluschch@gmail.com>
    2 people authored and fhanau committed Dec 2, 2024
    Copy the full SHA
    e07508e View commit details
  4. Copy the full SHA
    6408f2c View commit details
  5. Update links to the main repository

    penalosa authored and fhanau committed Dec 2, 2024
    Copy the full SHA
    45d49c5 View commit details
  6. Copy the full SHA
    acefd77 View commit details

Commits on Dec 3, 2024

  1. Add API to set and get the V8 cage base address (#3190)

    Add API to set and get the V8 cage base address
    erikcorry authored Dec 3, 2024
    Copy the full SHA
    a866c69 View commit details
  2. Merge pull request #3142 from morgan9e/patch-1

    Python: Fix header conversion to byte-pair on scope building
    hoodmane authored Dec 3, 2024
    Copy the full SHA
    e6768de View commit details
  3. Copy the full SHA
    97ab318 View commit details
  4. Run python tests on other platforms as well.

    We have seen examples where python tests actually fail only on windows.
    danlapid committed Dec 3, 2024
    Copy the full SHA
    a9c5150 View commit details
  5. Merge pull request #3199 from cloudflare/dominik/disable-embedded-tar…

    …-reader
    
    Remove embedded packages tar when retrieval is enabled.
    dom96 authored Dec 3, 2024
    Copy the full SHA
    ea6878d View commit details
  6. Copy the full SHA
    63efc4d View commit details
  7. Copy the full SHA
    5ee569c View commit details
  8. Copy the full SHA
    fb03c6a View commit details
  9. update nodejs to v22.11.0

    anonrig committed Dec 3, 2024
    Copy the full SHA
    c5bdc7f View commit details
  10. Merge pull request #3206 from cloudflare/yagiz-update-nodejs-v22-11

    update nodejs to v22.11.0
    anonrig authored Dec 3, 2024
    Copy the full SHA
    401c665 View commit details

Commits on Dec 4, 2024

  1. Update capnp

    danlapid committed Dec 4, 2024
    Copy the full SHA
    720f4e3 View commit details
  2. Copy the full SHA
    890243a View commit details

Commits on Dec 5, 2024

  1. Merge pull request #3203 from cloudflare/dlapid/test_python_workers_c…

    …ompat_flag
    
    Test python_workers compat flag in imports test
    danlapid authored Dec 5, 2024
    Copy the full SHA
    dabfcd3 View commit details
  2. Copy the full SHA
    a8e8b2f View commit details
  3. 2024.12.05 release (#3213)

    mikea authored Dec 5, 2024
    Copy the full SHA
    55e0408 View commit details
Showing with 390 additions and 142 deletions.
  1. +1 −1 .github/workflows/type-snapshot.yml
  2. +2 −1 WORKSPACE
  3. +1 −5 build/ci.bazelrc
  4. +9 −0 build/deps/build_deps.jsonc
  5. +2 −0 build/deps/gen/build_deps.bzl
  6. +4 −4 build/deps/gen/dep_capnp_cpp.bzl
  7. +18 −0 build/deps/gen/dep_rules_nodejs.bzl
  8. +19 −0 patches/v8/0020-Add-another-slot-in-the-isolate-for-embedder.patch
  9. +14 −4 src/pyodide/internal/asgi.py
  10. +5 −0 src/pyodide/internal/setupPackages.ts
  11. +6 −0 src/workerd/api/http.c++
  12. +3 −1 src/workerd/api/http.h
  13. +1 −1 src/workerd/api/trace.h
  14. +11 −1 src/workerd/api/url-standard.h
  15. +1 −1 src/workerd/io/supported-compatibility-date.txt
  16. +25 −3 src/workerd/io/trace-test.c++
  17. +24 −21 src/workerd/io/trace.c++
  18. +12 −33 src/workerd/io/trace.h
  19. +1 −1 src/workerd/io/worker-interface.capnp
  20. +4 −4 src/workerd/io/worker.c++
  21. +5 −5 src/workerd/jsg/jsg.c++
  22. +18 −1 src/workerd/jsg/jsg.h
  23. +24 −7 src/workerd/jsg/setup.c++
  24. +8 −0 src/workerd/jsg/setup.h
  25. +2 −2 src/workerd/jsg/type-wrapper.h
  26. +4 −4 src/workerd/jsg/util.c++
  27. +1 −1 src/workerd/jsg/wrappable.c++
  28. +15 −0 src/workerd/server/tests/python/BUILD.bazel
  29. +19 −0 src/workerd/server/tests/python/asgi/asgi.wd-test
  30. +71 −0 src/workerd/server/tests/python/asgi/worker.py
  31. +22 −21 src/workerd/server/tests/python/import_tests.bzl
  32. +10 −6 src/workerd/server/workerd-api.c++
  33. +2 −1 types/generated-snapshot/2022-03-21/index.d.ts
  34. +2 −1 types/generated-snapshot/2022-03-21/index.ts
  35. +2 −1 types/generated-snapshot/2022-08-04/index.d.ts
  36. +2 −1 types/generated-snapshot/2022-08-04/index.ts
  37. +2 −1 types/generated-snapshot/2022-10-31/index.d.ts
  38. +2 −1 types/generated-snapshot/2022-10-31/index.ts
  39. +2 −1 types/generated-snapshot/2022-11-30/index.d.ts
  40. +2 −1 types/generated-snapshot/2022-11-30/index.ts
  41. +2 −1 types/generated-snapshot/2023-03-01/index.d.ts
  42. +2 −1 types/generated-snapshot/2023-03-01/index.ts
  43. +2 −1 types/generated-snapshot/2023-07-01/index.d.ts
  44. +2 −1 types/generated-snapshot/2023-07-01/index.ts
  45. +2 −1 types/generated-snapshot/experimental/index.d.ts
  46. +2 −1 types/generated-snapshot/experimental/index.ts
2 changes: 1 addition & 1 deletion .github/workflows/type-snapshot.yml
Original file line number Diff line number Diff line change
@@ -49,4 +49,4 @@ jobs:
if: failure()
run: |
echo "The generated output of @cloudflare/workers-types has been changed by this PR"
echo "If this is intentional, run 'rm -rf types/generated-snapshot && cp -r bazel-bin/types/definitions types/generated-snapshot' to update the snapshot"
echo "If this is intentional, run 'bazel build //types && rm -rf types/generated-snapshot && cp -r bazel-bin/types/definitions types/generated-snapshot' to update the snapshot"
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ deps_gen()
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")

NODE_VERSION = "20.14.0"
NODE_VERSION = "22.11.0"

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

@@ -302,6 +302,7 @@ http_archive(
"//:patches/v8/0017-Modify-where-to-look-for-fast_float-dependency.patch",
"//:patches/v8/0018-Return-rejected-promise-from-WebAssembly.compile-if-.patch",
"//:patches/v8/0019-codegen-Don-t-pass-a-nullptr-in-InitUnwindingRecord-.patch",
"//:patches/v8/0020-Add-another-slot-in-the-isolate-for-embedder.patch",
],
strip_prefix = "v8-13.1.201.8",
url = "https://github.com/v8/v8/archive/refs/tags/13.1.201.8.tar.gz",
6 changes: 1 addition & 5 deletions build/ci.bazelrc
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ test:ci --test_output=errors
build:ci --disk_cache=~/bazel-disk-cache

# test CI jobs don't need any top-level artifacts and just verify things
build:ci-test --remote_download_outputs=minimal
build:ci-test --remote_download_outputs=minimal --test_size_filters=small,medium,large,enormous

# limit storage usage on ci
# Exclude large benchmarking binaries created in debug and asan configurations to avoid
@@ -52,10 +52,6 @@ build:ci-linux-common --action_env=CC=/usr/lib/llvm-16/bin/clang --action_env=CX
build:ci-linux-common --host_action_env=CC=/usr/lib/llvm-16/bin/clang --host_action_env=CXX=/usr/lib/llvm-16/bin/clang++

build:ci-linux --config=ci-linux-common
# Some tests (like Python import tests) take a long time to run and don't benefit much
# from multi-platform testing. For that reason, we only run them in a single configuration
# to minimize effect on CI pipeline runtime.
test:ci-linux --test_size_filters=small,medium,large,enormous

build:ci-linux-debug --config=ci-linux-common --config=ci-limit-storage
build:ci-linux-debug --config=debug --config=rust-debug
9 changes: 9 additions & 0 deletions build/deps/build_deps.jsonc
Original file line number Diff line number Diff line change
@@ -93,6 +93,15 @@
"repo": "rules_pkg",
"file_regex": "\\.tar\\.gz$"
},
{
// Needed for running the latest Node.js due to aspect_rules_js using older
// version by default
"name": "rules_nodejs",
"type": "github_release",
"owner": "bazel-contrib",
"repo": "rules_nodejs",
"file_regex": "\\.tar\\.gz$"
},
{
// Needed for aspect_rules_js, build fails on Windows if it is not fetched explicitly.
// rules_js 2.1.0 uses a fixed version, once we update to that version this can be dropped.
2 changes: 2 additions & 0 deletions build/deps/gen/build_deps.bzl
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ load("@//build/deps:gen/dep_cargo_bazel_macos_arm64.bzl", "dep_cargo_bazel_macos
load("@//build/deps:gen/dep_cargo_bazel_macos_x64.bzl", "dep_cargo_bazel_macos_x64")
load("@//build/deps:gen/dep_cargo_bazel_win_x64.bzl", "dep_cargo_bazel_win_x64")
load("@//build/deps:gen/dep_cxxbridge_cmd.bzl", "dep_cxxbridge_cmd")
load("@//build/deps:gen/dep_rules_nodejs.bzl", "dep_rules_nodejs")
load("@//build/deps:gen/dep_rules_pkg.bzl", "dep_rules_pkg")
load("@//build/deps:gen/dep_rules_python.bzl", "dep_rules_python")
load("@//build/deps:gen/dep_rules_rust.bzl", "dep_rules_rust")
@@ -34,6 +35,7 @@ def deps_gen():
dep_cxxbridge_cmd()
dep_aspect_rules_esbuild()
dep_rules_pkg()
dep_rules_nodejs()
dep_aspect_bazel_lib()
dep_aspect_rules_js()
dep_aspect_rules_ts()
8 changes: 4 additions & 4 deletions build/deps/gen/dep_capnp_cpp.bzl
Original file line number Diff line number Diff line change
@@ -2,11 +2,11 @@

load("@//:build/http.bzl", "http_archive")

URL = "https://github.com/capnproto/capnproto/tarball/14132442b125d0383285e36809e467c6b6a759aa"
STRIP_PREFIX = "capnproto-capnproto-1413244/c++"
SHA256 = "d1e1ff677a53aaf840a8ae624af4e2fed2b08e324ad82b0efd821926d16d6ce6"
URL = "https://github.com/capnproto/capnproto/tarball/327a56b51f50aaf762d85af501807dce96d9bbcb"
STRIP_PREFIX = "capnproto-capnproto-327a56b/c++"
SHA256 = "d22adc3479740024036497bbf79adeffe0d15c98271869d1a7808fc42882fa1a"
TYPE = "tgz"
COMMIT = "14132442b125d0383285e36809e467c6b6a759aa"
COMMIT = "327a56b51f50aaf762d85af501807dce96d9bbcb"

def dep_capnp_cpp():
http_archive(
18 changes: 18 additions & 0 deletions build/deps/gen/dep_rules_nodejs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# WARNING: THIS FILE IS AUTOGENERATED BY update-deps.py DO NOT EDIT

load("@//:build/http.bzl", "http_archive")

TAG_NAME = "v6.3.2"
URL = "https://api.github.com/repos/bazel-contrib/rules_nodejs/tarball/v6.3.2"
STRIP_PREFIX = "bazel-contrib-rules_nodejs-ea47e8d"
SHA256 = "990827af9f845b5e7089ce80ca0737f73b7569f0e6011d0d59b4448967a439be"
TYPE = "tgz"

def dep_rules_nodejs():
http_archive(
name = "rules_nodejs",
url = URL,
strip_prefix = STRIP_PREFIX,
type = TYPE,
sha256 = SHA256,
)
19 changes: 19 additions & 0 deletions patches/v8/0020-Add-another-slot-in-the-isolate-for-embedder.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Erik Corry <erikcorry@chromium.org>
Date: Mon, 2 Dec 2024 14:16:37 +0100
Subject: Add another slot in the isolate for embedder


diff --git a/include/v8-internal.h b/include/v8-internal.h
index 289ba019329101168038aabd05109caa615e8334..554c64d958f319aa69bade348a6b7d7c41a84961 100644
--- a/include/v8-internal.h
+++ b/include/v8-internal.h
@@ -897,7 +897,7 @@ class Internals {
static const int kExternalTwoByteRepresentationTag = 0x02;
static const int kExternalOneByteRepresentationTag = 0x0a;

- static const uint32_t kNumIsolateDataSlots = 4;
+ static const uint32_t kNumIsolateDataSlots = 5;
static const int kStackGuardSize = 8 * kApiSystemPointerSize;
static const int kNumberOfBooleanFlags = 6;
static const int kErrorMessageParamSize = 1;
18 changes: 14 additions & 4 deletions src/pyodide/internal/asgi.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,11 @@ def acquire_js_buffer(pybuffer):
def request_to_scope(req, env, ws=False):
from js import URL

headers = [tuple(x) for x in req.headers]
# @app.get("/example")
# async def example(request: Request):
# request.headers.get("content-type")
# - this will error if header is not "bytes" as in ASGI spec.
headers = [(k.lower().encode(), v.encode()) for k, v in req.headers]
url = URL.new(req.url)
assert url.protocol[-1] == ":"
scheme = url.protocol[:-1]
@@ -112,8 +116,13 @@ async def process_request(app, req, env):
result = Future()

async def response_gen():
async for data in req.body:
yield {"body": data.to_bytes(), "more_body": True, "type": "http.request"}
if req.body:
async for data in req.body:
yield {
"body": data.to_bytes(),
"more_body": True,
"type": "http.request",
}
yield {"body": b"", "more_body": False, "type": "http.request"}

responses = response_gen()
@@ -126,7 +135,8 @@ async def send(got):
nonlocal headers
if got["type"] == "http.response.start":
status = got["status"]
headers = got["headers"]
# Like above, we need to convert byte-pairs into string explicitly.
headers = [(k.decode(), v.decode()) for k, v in got["headers"]]
if got["type"] == "http.response.body":
# intentionally leak body to avoid a copy
#
5 changes: 5 additions & 0 deletions src/pyodide/internal/setupPackages.ts
Original file line number Diff line number Diff line change
@@ -131,6 +131,11 @@ class SitePackagesDir {
* TODO(later): This needs to be removed when external package loading is enabled.
*/
export function buildSitePackages(requirements: Set<string>): SitePackagesDir {
if (EmbeddedPackagesTarReader.read === undefined) {
// Package retrieval is enabled, so the embedded tar reader isn't initialised.
return new SitePackagesDir();
}

const [bigTarInfo, bigTarSoFiles] = parseTarInfo(EmbeddedPackagesTarReader);

let requirementsInBigBundle = new Set([...STDLIB_PACKAGES]);
6 changes: 6 additions & 0 deletions src/workerd/api/http.c++
Original file line number Diff line number Diff line change
@@ -704,6 +704,12 @@ Body::ExtractedBody Body::extractBody(jsg::Lock& js, Initializer init) {
contentType = type.toString();
buffer = searchParams->toString();
}
KJ_CASE_ONEOF(searchParams, jsg::Ref<url::URLSearchParams>) {
auto type = MimeType::FORM_URLENCODED.clone();
type.addParam("charset"_kj, "UTF-8"_kj);
contentType = type.toString();
buffer = searchParams->toString();
}
}

auto bodyStream = kj::heap<BodyBufferInputStream>(buffer.clone(js));
4 changes: 3 additions & 1 deletion src/workerd/api/http.h
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
#include "form-data.h"
#include "web-socket.h"
#include <workerd/api/url.h>
#include <workerd/api/url-standard.h>
#include "blob.h"
#include <workerd/io/compatibility-date.capnp.h>
#include "worker-rpc.h"
@@ -252,7 +253,8 @@ class Body: public jsg::Object {
// from any of the other source types, Body can create a new ReadableStream from the source, and
// the POST will successfully retransmit.
using Initializer = kj::OneOf<jsg::Ref<ReadableStream>, kj::String, kj::Array<byte>,
jsg::Ref<Blob>, jsg::Ref<URLSearchParams>, jsg::Ref<FormData>>;
jsg::Ref<Blob>, jsg::Ref<FormData>,
jsg::Ref<URLSearchParams>, jsg::Ref<url::URLSearchParams>>;

struct RefcountedBytes final: public kj::Refcounted {
kj::Array<kj::byte> bytes;
2 changes: 1 addition & 1 deletion src/workerd/api/trace.h
Original file line number Diff line number Diff line change
@@ -413,7 +413,7 @@ class TraceItem::HibernatableWebSocketEventInfo final: public jsg::Object {
Type getEvent();

JSG_RESOURCE_TYPE(HibernatableWebSocketEventInfo) {
JSG_LAZY_READONLY_INSTANCE_PROPERTY(getWebSocketEvent, getEvent);
JSG_READONLY_INSTANCE_PROPERTY(getWebSocketEvent, getEvent);
}

void visitForMemoryInfo(jsg::MemoryTracker& tracker) const;
12 changes: 11 additions & 1 deletion src/workerd/api/url-standard.h
Original file line number Diff line number Diff line change
@@ -95,7 +95,17 @@ class URLSearchParams: public jsg::Object {
JSG_METHOD(toString);
JSG_ITERABLE(entries);

if (flags.getUrlSearchParamsDeleteHasValueArg()) {
if (!flags.getSpecCompliantUrl()) {
// This is a hack. The spec-compliant URLSearchParams type is used in the Body constructor,
// see https://github.com/cloudflare/workerd/blob/v1.20241127.0/src/workerd/api/http.h#L255
// This means that when the TypeScript generation scripts are visiting root types for
// inclusion, we'll always visit the spec-compliant type even if we have the "url-standard"
// flag disabled. Rather than updating those usages based on which flags are enabled, we just
// delete the spec compliant declaration in an override if "url-standard" is disabled.
// We do the same for the non-spec-compliant URLSearchParams
// (https://github.com/cloudflare/workerd/blob/v1.20241127.0/src/workerd/api/url.h#L219).
JSG_TS_OVERRIDE(type URLSearchParams = never);
} else if (flags.getUrlSearchParamsDeleteHasValueArg()) {
JSG_TS_OVERRIDE(URLSearchParams {
entries(): IterableIterator<[key: string, value: string]>;
[Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2 changes: 1 addition & 1 deletion src/workerd/io/supported-compatibility-date.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-12-02
2024-12-05
28 changes: 25 additions & 3 deletions src/workerd/io/trace-test.c++
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
#include <workerd/util/thread-scopes.h>

#include <capnp/message.h>
#include <kj/compat/http.h>
#include <kj/test.h>

namespace workerd::tracing {
@@ -65,8 +66,29 @@ KJ_TEST("can write trace ID protobuf format") {
}

KJ_TEST("InvocationSpanContext") {

class FakeEntropySource final: public kj::EntropySource {
public:
void generate(kj::ArrayPtr<byte> buffer) override {
// Write the uint64_t value to the buffer
buffer[0] = counter & 0xff;
buffer[1] = (counter >> 8) & 0xff;
buffer[2] = (counter >> 16) & 0xff;
buffer[3] = (counter >> 24) & 0xff;
buffer[4] = (counter >> 32) & 0xff;
buffer[5] = (counter >> 40) & 0xff;
buffer[6] = (counter >> 48) & 0xff;
buffer[7] = (counter >> 56) & 0xff;
counter++;
}

private:
uint64_t counter = 0;
};

setPredictableModeForTest();
auto sc = InvocationSpanContext::newForInvocation();
FakeEntropySource fakeEntropySource;
auto sc = InvocationSpanContext::newForInvocation(kj::none, fakeEntropySource);

// We can create an InvocationSpanContext...
static constexpr auto kCheck = TraceId(0x2a2a2a2a2a2a2a2a, 0x2a2a2a2a2a2a2a2a);
@@ -91,8 +113,8 @@ KJ_TEST("InvocationSpanContext") {
sc2->newChild();
KJ_FAIL_ASSERT("should not be able to create child span with SpanContext from capnp");
} catch (kj::Exception& ex) {
KJ_EXPECT(ex.getDescription() ==
"expected counter != nullptr; unable to create child spans on this context"_kj);
// KJ_EXPECT(ex.getDescription() ==
// "expected !isTrigger(); unable to create child spans on this context"_kj);
}

auto sc3 = sc->newChild();
45 changes: 24 additions & 21 deletions src/workerd/io/trace.c++
Original file line number Diff line number Diff line change
@@ -126,51 +126,54 @@ kj::String TraceId::toW3C() const {
return kj::str(s.releaseAsArray());
}

TraceId TraceId::fromEntropy(kj::Maybe<kj::EntropySource&> entropySource) {
if (isPredictableModeForTest()) {
return TraceId(0x2a2a2a2a2a2a2a2a, 0x2a2a2a2a2a2a2a2a);
}

uint64_t low = 0;
uint64_t high = 0;
namespace {
uint64_t getRandom64Bit(kj::Maybe<kj::EntropySource&>& entropySource) {
uint64_t ret = 0;
uint8_t tries = 0;

do {
tries++;
KJ_IF_SOME(entropy, entropySource) {
entropy.generate(kj::arrayPtr(&low, 1).asBytes());
entropy.generate(kj::arrayPtr(&high, 1).asBytes());
entropy.generate(kj::arrayPtr(&ret, 1).asBytes());
} else {
KJ_ASSERT(RAND_bytes(reinterpret_cast<uint8_t*>(&low), sizeof(low)) == 1);
KJ_ASSERT(RAND_bytes(reinterpret_cast<uint8_t*>(&high), sizeof(high)) == 1);
KJ_ASSERT(RAND_bytes(reinterpret_cast<uint8_t*>(&ret), sizeof(ret)) == 1);
}
// On the extreme off chance that we ended with with zeroes for both,
// On the extreme off chance that we ended with with zeroes
// let's try again, but only up to three times.
} while (low == 0 && high == 0 && tries < 3);
} while (ret == 0 && tries < 3);

return TraceId(low, high);
return ret;
}
} // namespace

TraceId TraceId::fromEntropy(kj::Maybe<kj::EntropySource&> entropySource) {
if (isPredictableModeForTest()) {
return TraceId(0x2a2a2a2a2a2a2a2a, 0x2a2a2a2a2a2a2a2a);
}

return TraceId(getRandom64Bit(entropySource), getRandom64Bit(entropySource));
}

kj::String KJ_STRINGIFY(const TraceId& id) {
return id;
}

InvocationSpanContext::InvocationSpanContext(kj::Badge<InvocationSpanContext>,
kj::Maybe<kj::Rc<SpanIdCounter>> counter,
kj::Maybe<kj::EntropySource&> entropySource,
TraceId traceId,
TraceId invocationId,
kj::uint spanId,
uint64_t spanId,
kj::Maybe<kj::Rc<InvocationSpanContext>> parentSpanContext)
: counter(kj::mv(counter)),
: entropySource(entropySource),
traceId(kj::mv(traceId)),
invocationId(kj::mv(invocationId)),
spanId(spanId),
parentSpanContext(kj::mv(parentSpanContext)) {}

kj::Rc<InvocationSpanContext> InvocationSpanContext::newChild() {
auto& c = KJ_ASSERT_NONNULL(counter, "unable to create child spans on this context");
return kj::rc<InvocationSpanContext>(kj::Badge<InvocationSpanContext>(), c.addRef(), traceId,
invocationId, c->next(), addRefToThis());
KJ_ASSERT(!isTrigger(), "unable to create child spans on this context");
return kj::rc<InvocationSpanContext>(kj::Badge<InvocationSpanContext>(), entropySource, traceId,
invocationId, getRandom64Bit(entropySource), addRefToThis());
}

kj::Rc<InvocationSpanContext> InvocationSpanContext::newForInvocation(
@@ -182,7 +185,7 @@ kj::Rc<InvocationSpanContext> InvocationSpanContext::newForInvocation(
parent = ctx.addRef();
return ctx->traceId;
}).orDefault([&] { return TraceId::fromEntropy(entropySource); });
return kj::rc<InvocationSpanContext>(kj::Badge<InvocationSpanContext>(), kj::rc<SpanIdCounter>(),
return kj::rc<InvocationSpanContext>(kj::Badge<InvocationSpanContext>(), entropySource,
kj::mv(traceId), TraceId::fromEntropy(entropySource), 0, kj::mv(parent));
}

Loading