cloudflare / cloudflare/workerd

🐛 Bug Report — Runtime APIs, Reflect.set doesn't respect spread operator for functions

Open
#671 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8.7k
Forks
739
Avg merge
2d 20h
Merged PRs (30d)
174

Description

```
const object = {}
const toBeSpread = { spreadConst: "foo", spreadFunc: () => "foo"}
Reflect.set(object, Symbol.for("set"), { ...toBeSpread })
const get = Reflect.get(object, Symbol.for("set"))
console.log(get)
```
workerd output:
```workerd/io/worker.c++:1544: info: console.log(); message() = [{"spreadConst":"foo"}]```

![Screenshot 2023-05-19 at 12 05 14](https://github.com/cloudflare/workerd/assets/110818305/0ce70818-5f9e-4712-b758-5c74386cc62c)

node output:
```{ spreadConst: 'foo', spreadFunc: [Function: spreadFunc] }```

This functionality is used in the [Cloudflare Astro Integration](https://github.com/withastro/astro/blob/530fb9ebee77646921ec29d45d9b66484bdfb521/packages/integrations/cloudflare/src/server.advanced.ts#L34) to expose the context object of a request.

Without this functionality, I'm struggling to use functions like waitUntil.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.