CodeSampleX

Exemplo

bun 1.3.14: Demonstrate that FileSink.write() silently drops data without throwing when called after end()

Amostra verificada para npm bun 1.3.14: Demonstrate that FileSink.write() silently drops data without throwing when called after end(). O contrato rodou em…

sha256:c1c480ed510e810ccbaf4d54ffc634d50cbd65350d75dd816b669716d0080ae7

Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu. Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas. MIT-0

Evidência de execução

O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.

Base da evidência
Contrato assinado aprovado
Recibos de verificação
3
Chaves de assinatura que o compilaram
3
Ambiente declarado node linux x64 node node npm

Ambientes das execuções de verificação

Ambiente Contrato Etapas Execução
node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-17
node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-18
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-09-07

Caso

HOW
Objetivo
Demonstrate that FileSink.write() silently drops data without throwing when called after end()
Pacotes
Símbolos
  • Bun.file
Ambiente
node
Criado
2026-08-17T03:51:34Z

Contrato

  1. const file = Bun.file('data.bin');
  2. const writer = file.writer();
  3. writer.end();
  4. const res = writer.write('A');
  5. assert.strictEqual(res, true, 'write() on a closed FileSink returns true rather than throwing an error');
  6. assert.strictEqual(await file.text(), '', 'Data written after end() is silently discarded');

Arquivos

  • csx.json
  • package-lock.json
  • package.json
  • test/bun-binary.mjs
  • test/contract.mjs

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

csx.json
{"case":{"believed":"Calling write() on a closed FileSink throws an error or rejects, just like writing to a closed stream in Node.js or web streams.","caseId":"case:sha256:713aef93cf08dcb7b98a39d69f732664d75f96d7d5b584d21e55258b067b8a59","contract":["const file = Bun.file('data.bin');","const writer = file.writer();","writer.end();","const res = writer.write('A');","assert.strictEqual(res, true, 'write() on a closed FileSink returns true rather than throwing an error');","assert.strictEqual(await file.text(), '', 'Data written after end() is silently discarded');"],"goal":"Demonstrate that FileSink.write() silently drops data without throwing when called after end()","kind":"HOW","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.file"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/bun@1.3.14"],"schemaVersion":1,"symbols":["Bun.file"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "npm-bun-d6",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "npm-bun-d6",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "bun": "1.3.14"
      }
    },
    "node_modules/@oven/bun-darwin-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-aarch64/-/bun-darwin-aarch64-1.3.14.tgz",
      "integrity": "sha512-Omj20SuiHBOUjUBIyqtkNjSUIjOtEOJwmbix/ZyFH4BaQ6OZTaaRWIR4TjHVz0yadHgli6lLTiAh1uarnvD49A==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-darwin-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64/-/bun-darwin-x64-1.3.14.tgz",
      "integrity": "sha512-FFj3QdU/OhlDyZOJ8CWfN5eWLpRlT4qjZg7lMQi7jA6GuoY5ajlO1zWLP/MuHYRSbXQUvV52RejNi8DVnAp13w==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-darwin-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-darwin-x64-baseline/-/bun-darwin-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-OSfsTZstc898HHElhU4NccaBGOSSDn5VfahiVTnidZ9B/+wb7WTyfZJaBeJcfjwJ9H2W9uTh2TGtl3UfcXgV9g==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "darwin"
      ]
    },
    "node_modules/@oven/bun-freebsd-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-freebsd-aarch64/-/bun-freebsd-aarch64-1.3.14.tgz",
      "integrity": "sha512-LIKrXaFxAHybVO5Pf+9XP2FHUj/5APvXTUKk9dqHm5iFz4oH+W24cmhjkJirNujh9hKeTyrpWSe3no9JZKowIw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@oven/bun-freebsd-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-freebsd-x64/-/bun-freebsd-x64-1.3.14.tgz",
      "integrity": "sha512-uwD+fGUH1ADpIF3B1U2jWzzb20QwRLZfj5QZ28GUCGrAJ/nTmWrD6YYGsblCY1wuhldRez3lU40AyuvSCyLYmw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "freebsd"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64/-/bun-linux-aarch64-1.3.14.tgz",
      "integrity": "sha512-X5SsPZHs+iYO8R/efIcRtc7gT2Q2DgPfliCxEkx4cXBumwkw0c/EsHMNwH3EgGpCDaZ7IYVPhpCG/xBOQHEwZw==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64-android": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-android/-/bun-linux-aarch64-android-1.3.14.tgz",
      "integrity": "sha512-y4kq5b85lsrmFb9Xvi4w9mA5IEFJkLMrSmYn06q24KjL9rUWDWO3VFZEtteZxUN5+ec3Zm5S8OnJw1umaCbVjA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@oven/bun-linux-aarch64-musl": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-aarch64-musl/-/bun-linux-aarch64-musl-1.3.14.tgz",
      "integrity": "sha512-jmqOA92Cd1NL/1XBd4bFkJLxQ86K0RW7ohxS2qzzAvuitO4JiIxjjTeCspoU44zCozH72HpfZfUE2On31OjnWA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64/-/bun-linux-x64-1.3.14.tgz",
      "integrity": "sha512-7OVTAKvwfPmSbIV1HpdOoVVx5VRc427GuPPne93N6vk4eQBPId9nXmZDh9/zGaKPdbVjVtQSZafWQoUjx38Utw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-android": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-android/-/bun-linux-x64-android-1.3.14.tgz",
      "integrity": "sha512-qe9e1d+3VAEU7nAA2ol9Jvmy/o99PVMSgZhHn7Q/9O3YcDrfEqyQ8zm4zoe5qTEo8HZH0dN03Le0Ys2eQPs7eg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "android"
      ]
    },
    "node_modules/@oven/bun-linux-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-baseline/-/bun-linux-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-q/8EdOC0yUE8FPeoOVq8/Pw5I9/tJaYmUfO/uDUAREx8IUnOJH1RJ5A3BjFqre8pvJoiZA9AovPJq5FnNNjSxA==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-musl": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl/-/bun-linux-x64-musl-1.3.14.tgz",
      "integrity": "sha512-GBCB/k/sIqcr06eTNgg7g46qiUv35Jasx4XiccJ/n7RGqrE4RWUD/XJBbWFprVPjvqd59+QtSnS99XGqvftHfg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-linux-x64-musl-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-linux-x64-musl-baseline/-/bun-linux-x64-musl-baseline-1.3.14.tgz",
      "integrity": "sha512-n6iE71G4lQE4XkrZhQQcL5YUlxDbnq6nqV7zeQi33PMsLT/0kYE+RvHOtBWZ3w0wMdXZfINmp63hIb9ijUBGtw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "linux"
      ]
    },
    "node_modules/@oven/bun-windows-aarch64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-aarch64/-/bun-windows-aarch64-1.3.14.tgz",
      "integrity": "sha512-T7s3x/BsVKQObGU6QDkZeI6wKynzqGbBH1yI77jrrj5siElclxr3DQrDIk8CV4G5/SJq2HHq4kpLyYY2DKCSmA==",
      "cpu": [
        "arm64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@oven/bun-windows-x64": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64/-/bun-windows-x64-1.3.14.tgz",
      "integrity": "sha512-mUFWL3BoYkNpjd8e9PqROiFF/1Xeotq20mABJsiQH62jM1g5zqWh4khw1RZ6bX8Q8fWvlPaxG1PjofkmjUi3vg==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/@oven/bun-windows-x64-baseline": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@oven/bun-windows-x64-baseline/-/bun-windows-x64-baseline-1.3.14.tgz",
      "integrity": "sha512-uIjLUC1S9DWgICzuoMba7vurBJnBruE4S5CxnvmZkdqWVXRzx1Rgu636HoH+k0qeaQCFh3jeG3JQ1y6fRHv0sw==",
      "cpu": [
        "x64"
      ],
      "license": "MIT",
      "optional": true,
      "os": [
        "win32"
      ]
    },
    "node_modules/bun": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/bun/-/bun-1.3.14.tgz",
      "integrity": "sha512-aB6GVd42x1Y5ie1K16SF+oLGtgSkwX9hgoDdIW88pjvfTccU8F1vfpoOt34QLv0dZ1v3XimtaxPlZUG81Gx9Zg==",
      "cpu": [
        "arm64",
        "x64"
      ],
      "hasInstallScript": true,
      "license": "MIT",
      "os": [
        "darwin",
        "linux",
        "android",
        "freebsd",
        "win32"
      ],
      "bin": {
        "bun": "bin/bun.exe",
        "bunx": "bin/bunx.exe"
      },
      "optionalDependencies": {
        "@oven/bun-darwin-aarch64": "1.3.14",
        "@oven/bun-darwin-x64": "1.3.14",
        "@oven/bun-darwin-x64-baseline": "1.3.14",
        "@oven/bun-freebsd-aarch64": "1.3.14",
        "@oven/bun-freebsd-x64": "1.3.14",
        "@oven/bun-linux-aarch64": "1.3.14",
        "@oven/bun-linux-aarch64-android": "1.3.14",
        "@oven/bun-linux-aarch64-musl": "1.3.14",
        "@oven/bun-linux-x64": "1.3.14",
        "@oven/bun-linux-x64-android": "1.3.14",
        "@oven/bun-linux-x64-baseline": "1.3.14",
        "@oven/bun-linux-x64-musl": "1.3.14",
        "@oven/bun-linux-x64-musl-baseline": "1.3.14",
        "@oven/bun-windows-aarch64": "1.3.14",
        "@oven/bun-windows-x64": "1.3.14",
        "@oven/bun-windows-x64-baseline": "1.3.14"
      }
    }
  }
}
package.json
{
  "name": "npm-bun-d6",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "license": "MIT-0",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "bun": "1.3.14"
  }
}
test/bun-binary.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

function isMuslLinux() {
  if (process.platform !== 'linux') return false;
  if (fs.existsSync('/etc/alpine-release')) return true;
  return !process.report?.getReport?.().header?.glibcVersionRuntime;
}

export function findBunBinary() {
  const packageJsonPath = require.resolve('bun/package.json');
  const packageDirectory = path.dirname(packageJsonPath);
  const metadata = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
  const executable = process.platform === 'win32' ? 'bun.exe' : 'bun';
  const packageArchitecture = process.arch === 'arm64' ? 'aarch64' : process.arch;
  const candidates = [];

  if (isMuslLinux()) {
    if (packageArchitecture === 'x64') {
      candidates.push('@oven/bun-linux-x64-musl-baseline');
    }
    candidates.push(`@oven/bun-linux-${packageArchitecture}-musl`);
  } else {
    candidates.push(null);
  }

  const paths = candidates.map((packageName) => packageName
    ? path.join(packageDirectory, '..', ...packageName.split('/'), 'bin', executable)
    : path.join(packageDirectory, 'bin', executable));
  const binary = paths.find((candidate) => fs.existsSync(candidate));
  assert.ok(binary, 'resolved bun package must contain a compatible platform executable');
  return { binary, metadata };
}
test/contract.mjs
import assert from 'node:assert/strict';
import { spawnSync } from 'node:child_process';
import { findBunBinary } from './bun-binary.mjs';

const { binary: bunBinary, metadata } = findBunBinary();
const version = spawnSync(bunBinary, ['--version'], { encoding: 'utf8' });
assert.strictEqual(version.status, 0, version.stderr);
assert.strictEqual(version.stdout.trim(), metadata.version);

const contract = String.raw`
import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';

const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'csx-filesink-'));
const output = path.join(directory, 'output.bin');
try {
  const file = Bun.file(output);
  const writer = file.writer();
  await writer.end();
  const result = writer.write('A');
  assert.strictEqual(result, true);
  assert.strictEqual(await file.text(), '');
  console.log(JSON.stringify({ status: 'PASS' }));
} finally {
  fs.rmSync(directory, { recursive: true, force: true });
}
`;

const run = spawnSync(bunBinary, ['-e', contract], { encoding: 'utf8' });
assert.strictEqual(run.status, 0, `Bun contract failed:\n${run.stdout}\n${run.stderr}`);
assert.deepStrictEqual(JSON.parse(run.stdout.trim()), { status: 'PASS' });

Seeder de origem

csx-seed