Skip to content

fix(examples): correct claimed output that does not match what runs - #3500

Open
yxshee wants to merge 1 commit into
denoland:mainfrom
yxshee:fix/example-output-claims
Open

yxshee wants to merge 1 commit into
denoland:mainfrom
yxshee:fix/example-output-claims

Conversation

@yxshee

@yxshee yxshee commented Oct 26, 2026

Copy link
Copy Markdown

Summary

I ran every script in examples/scripts/ with Deno 2.9.6 and compared each // output comment with what the line actually printed. I also ran the console snippets in the debugging tutorial. These are the ones that print something else, on any machine:

  • examples/scripts/mime_type.ts: contentType(".json") returns application/json; charset=UTF-8, not application/json. This affects two lines. The fallback case used archive.xyz, but .xyz is a known type (chemical/x-xyz), so the fallback never ran. I changed it to archive.unknown, which returns undefined.
  • examples/scripts/url_parsing.ts: setting host and protocol keeps the path. href is http://deno.com/api/deno?s=Deno.readFile, not http://deno.com/api?s=Deno.readFile.
  • examples/scripts/ulid.ts: monotonicUlid(150000) always starts with 0000004JFG, because the first 10 characters encode the time. The old values started with 000XAL6S41, which is a different time and has an L, a letter that is not in the ULID alphabet. I replaced them with real output and added one line saying the tail is random.
  • examples/scripts/subprocess_env_cwd.ts: with clearEnv: true the child printed has PATH: true. The child is deno eval, and Deno puts its node shim directory on PATH when no node is found (documented in runtime/fundamentals/node.md). The example now checks HOME, which prints has HOME: false, and the comment says why.
  • examples/tutorials/debugging_with_console.md: console.log("Hello, ", person.name, "from ", person.city) prints Hello, Jane from New York with double spaces, and the template literal version had no comma. I fixed the code so both print the claimed Hello, Jane from New York. The console.table output also right-aligns numbers, so I updated those two rows. I bumped last_modified.

How I checked

  • I ran each changed example with deno run -A and logged the line number of every console.log call, then compared the output with the comment on that line. All claims in the changed files now match. For ulid.ts the random tail differs per run, but the 0000004JFG prefix and the +1 steps match.
  • env -i deno eval "console.log(Deno.env.toObject())" prints PATH and DENO_NODE_SHIM_ACTIVE, and with DENO_DISABLE_NODE_SHIM=1 it prints neither. This is why the old PATH check was wrong.
  • deno fmt --check passes. deno task check:freshness passes. frontmatter_test.ts, sidebar_test.ts and api_links_test.ts pass.

- mime_type: contentType(".json") includes "; charset=UTF-8", and ".xyz"
  is a known extension (chemical/x-xyz), so use ".unknown" for the
  fallback case.
- url_parsing: changing host and protocol keeps the path, so href is
  http://deno.com/api/deno?s=Deno.readFile.
- ulid: monotonicUlid(150000) starts with 0000004JFG. The old values
  encoded a different time and contained "L", which is not in the ULID
  alphabet.
- subprocess_env_cwd: a Deno child adds its node shim directory to PATH
  even with clearEnv, so the example printed "has PATH: true". Check
  HOME instead.
- debugging_with_console: the comma-separated console.log printed
  double spaces, the template literal had no comma, and console.table
  right-aligns numbers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NQDmA3mwGfL83pbg9WQ6ey

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant