Compare commits

...

9 Commits

Author SHA1 Message Date
Jarred Sumner
cbdbc95492 Speculative fix for napi_set_property crash 2024-05-04 22:37:35 -07:00
Jarred Sumner
60a8ad0b27 Support passing Subprocess stdout/stderr to Bun.serve() 2024-05-04 19:20:32 -07:00
Jarred Sumner
69f5c93b45 Update installation.md 2024-05-03 20:22:00 -07:00
Ashcon Partovi
541744e583 Improve node:inspector stubs (#10807) 2024-05-03 19:44:30 -07:00
Eric L. Goldstein
d1eb35dd5d Update documentation for the [dir] option when customizing bundler naming (#10804) 2024-05-03 19:14:25 -07:00
Jarred Sumner
31d3d527f4 Update installation.md 2024-05-03 19:07:47 -07:00
Jarred Sumner
01fade7b1f Update installation.md 2024-05-03 19:06:13 -07:00
Jarred Sumner
669b47375f Add JS/TS code field to crash report template 2024-05-03 16:30:05 -07:00
Jared McCannon
d6d1a0bec8 Update solidstart.md (#10810) 2024-05-03 14:14:51 -07:00
11 changed files with 149 additions and 28 deletions

View File

@@ -7,11 +7,17 @@ body:
- type: markdown
attributes:
value: |
Thank you for submitting a crash report. It helps make Bun better.
Thank you so much for submitting a crash report. You're helping us make Bun more reliable for everyone!
- type: textarea
attributes:
label: How can we reproduce the crash?
description: Please provide instructions on how to reproduce the crash.
- type: textarea
id: code
attributes:
label: JavaScript/TypeScript code that reproduces the crash?
description: If this crash happened in the Bun runtime, can you paste code we can run to reproduce the crash?
render: shell
- type: textarea
id: logs
attributes:

View File

@@ -792,7 +792,7 @@ The names and locations of the generated files can be customized with the `namin
- `[name]` - The name of the entrypoint file, without the extension.
- `[ext]` - The extension of the generated bundle.
- `[hash]` - A hash of the bundle contents.
- `[dir]` - The relative path from the build root to the parent directory of the file.
- `[dir]` - The relative path from the project root to the parent directory of the source file.
For example:

View File

@@ -55,4 +55,4 @@ Open [localhost:3000](http://localhost:3000). Any changes you make to `src/route
---
Refer to the [SolidStart website](start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.
Refer to the [SolidStart website](https://start.solidjs.com/getting-started/what-is-solidstart) for complete framework documentation.

View File

@@ -1,4 +1,4 @@
Bun ships as a single executable that can be installed a few different ways.
Bun ships as a single executable with no dependencies that can be installed a few different ways.
## Installing
@@ -38,10 +38,6 @@ $ proto install bun
### Windows
{% callout %}
Bun requires a minimum of Windows 10 version 1809
{% /callout %}
To install, paste this into a terminal:
{% codetabs %}
@@ -60,6 +56,10 @@ To install, paste this into a terminal:
{% /codetabs %}
{% callout %}
Bun requires a minimum of Windows 10 version 1809
{% /callout %}
For support and discussion, please join the [#windows channel on our Discord](http://bun.sh/discord).
## Docker
@@ -149,18 +149,60 @@ $ bun upgrade
**proto users** - Use `proto install bun --pin` instead.
{% /callout %}
## Canary builds
Bun automatically releases an (untested) canary build on every commit to `main`. To upgrade to the latest canary build:
```sh
$ bun upgrade --canary
```
The canary build is useful for testing new features and bug fixes before they're released in a stable build. To help the Bun team fix bugs faster, canary builds automatically upload crash reports to Bun's team.
[View canary build](https://github.com/oven-sh/bun/releases/tag/canary)
{% callout %}
**Note** — To switch back to a stable release from canary, run `bun upgrade` again with no flags.
**Note** — To switch back to a stable release from canary, run `bun upgrade` again with no flags.
{% /callout %}
## Installing older versions of Bun
Since Bun is a single binary, you can install older versions of Bun by re-running the installer script with a specific version.
### Installing a specific version of Bun on Linux/Mac
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.1.6` or `bun-v1.1.1`.
```sh
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.1.6"
```
### Installing a specific version of Bun on Windows
On Windows, you can install a specific version of Bun by passing the version number to the Powershell install script.
```sh
# PowerShell:
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.1.6"
```
## Downloading Bun binaries directly
To download Bun binaries directly, you can visit the [releases page](https://github.com/oven-sh/bun/releases) page on GitHub.
For convenience, here are download links for the latest version:
- [`bun-linux-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip)
- [`bun-linux-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64-baseline.zip)
- [`bun-windows-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64.zip)
- [`bun-windows-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-windows-x64-baseline.zip)
- [`bun-darwin-aarch64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-aarch64.zip)
- [`bun-linux-aarch64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-linux-aarch64.zip)
- [`bun-darwin-x64.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-x64.zip)
- [`bun-darwin-x64-baseline.zip`](https://github.com/oven-sh/bun/releases/latest/download/bun-darwin-x64-baseline.zip)
The `baseline` binaries are built for older CPUs which may not support AVX2 instructions. If you run into an "Illegal Instruction" error when running Bun, try using the `baseline` binaries instead. Bun's install scripts automatically choose the correct binary for your system which helps avoid this issue. Baseline builds are slower than regular builds, so use them only if necessary.
<!--
## Native

View File

@@ -2823,10 +2823,13 @@ fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool, comp
.Invalid => {
this.readable_stream_ref.deinit();
},
// toBlobIfPossible should've caught this
.Blob, .File => unreachable,
.JavaScript, .Direct => {
// toBlobIfPossible will typically convert .Blob streams, or .File streams into a Blob object, but cannot always.
.Blob,
.File,
// These are the common scenario:
.JavaScript,
.Direct,
=> {
if (this.resp) |resp| {
var pair = StreamPair{ .stream = stream, .this = this };
resp.runCorkedWithType(*StreamPair, doRenderStream, &pair);

View File

@@ -494,24 +494,35 @@ extern "C" napi_status napi_set_property(napi_env env, napi_value target,
return napi_invalid_arg;
}
auto globalObject = toJS(env);
auto& vm = globalObject->vm();
auto* object = toJS(target).getObject();
if (!object) {
JSValue targetValue = toJS(target);
if (!targetValue.isObject()) {
return napi_object_expected;
}
auto globalObject = toJS(env);
auto& vm = globalObject->vm();
auto* object = targetValue.getObject();
auto keyProp = toJS(key);
auto scope = DECLARE_CATCH_SCOPE(vm);
PutPropertySlot slot(object, true);
Identifier identifier = keyProp.toPropertyKey(globalObject);
JSValue jsValue = toJS(value);
PutPropertySlot slot(object, false);
object->put(object, globalObject, identifier, jsValue, slot);
Identifier identifier = keyProp.toPropertyKey(globalObject);
RETURN_IF_EXCEPTION(scope, napi_generic_failure);
scope.clearException();
JSValue jsValue = toJS(value);
if (!object->put(object, globalObject, identifier, jsValue, slot)) {
scope.clearExceptionExceptTermination();
return napi_generic_failure;
}
if (UNLIKELY(scope.exception())) {
scope.clearException();
return napi_generic_failure;
}
return napi_ok;
}
extern "C" napi_status napi_has_property(napi_env env, napi_value object,

View File

@@ -4,25 +4,27 @@ const { hideFromStack, throwNotImplemented } = require("internal/shared");
const EventEmitter = require("node:events");
function open() {
throwNotImplemented("node:inspector open", 2445);
throwNotImplemented("node:inspector", 2445);
}
function close() {
throwNotImplemented("node:inspector close", 2445);
throwNotImplemented("node:inspector", 2445);
}
function url() {
throwNotImplemented("node:inspector url", 2445);
// Return undefined since that is allowed by the Node.js API
// https://nodejs.org/api/inspector.html#inspectorurl
return undefined;
}
function waitForDebugger() {
throwNotImplemented("node:inspector waitForDebugger", 2445);
throwNotImplemented("node:inspector", 2445);
}
class Session extends EventEmitter {
constructor() {
super();
throwNotImplemented("node:inspector Session", 2445);
throwNotImplemented("node:inspector", 2445);
}
}

View File

@@ -269,7 +269,7 @@ export function randomPort(): number {
}
expect.extend({
toRun(cmds: string[]) {
toRun(cmds: string[], optionalStdout?: string) {
const result = Bun.spawnSync({
cmd: [bunExe(), ...cmds],
env: bunEnv,
@@ -283,6 +283,14 @@ expect.extend({
};
}
if (optionalStdout) {
return {
pass: result.stdout.toString("utf-8") === optionalStdout,
message: () =>
`Expected ${cmds.join(" ")} to output ${optionalStdout} but got ${result.stdout.toString("utf-8")}`,
};
}
return {
pass: true,
message: () => `Expected ${cmds.join(" ")} to fail`,

View File

@@ -0,0 +1,20 @@
import { spawn, serve } from "bun";
const server = serve({
port: 0,
async fetch(req) {
const { stdout } = spawn({
cmd: [process.execPath, "--eval", 'console.write("hello world")'],
env: process.env,
stdout: "pipe",
stderr: "inherit",
stdin: "ignore",
});
return new Response(stdout);
},
});
const response = await fetch(server.url);
console.write(await response.text());
server.stop(true);

View File

@@ -0,0 +1,7 @@
import { test, expect } from "bun:test";
import "harness";
import { fileURLToPath } from "url";
test("Subprocess stdout can be used in Bun.serve()", async () => {
expect([fileURLToPath(import.meta.resolve("./spawn-stream-http-fixture.js"))]).toRun("hello world");
});

View File

@@ -0,0 +1,22 @@
import { test, expect } from "bun:test";
import inspector from "node:inspector";
test("inspector.url()", () => {
expect(inspector.url()).toBeUndefined();
});
test("inspector.console", () => {
expect(inspector.console).toBeObject();
});
test("inspector.open()", () => {
expect(() => inspector.open()).toThrow(/not yet implemented/);
});
test("inspector.close()", () => {
expect(() => inspector.close()).toThrow(/not yet implemented/);
});
test("inspector.waitForDebugger()", () => {
expect(() => inspector.waitForDebugger()).toThrow(/not yet implemented/);
});