fix: init validation, build-sbf lockfile, profile server truncation#99
Merged
fix: init validation, build-sbf lockfile, profile server truncation#99
Conversation
Extract validate_target_dir() from scaffold() and call it in run() immediately after the project name is resolved. Directory and config checks (existing Quasar.toml, Cargo.toml, non-empty dir) now run before the user is prompted for toolchain, test language, template, and git setup. Closes #91
The Solana toolchain bundles cargo 1.84, which cannot parse crate manifests that use edition 2024. When a scaffolded project has no Cargo.lock, Solana's cargo attempts full dependency resolution and fails on transitive dependencies like toml_datetime >= 1.1. Two-layer fix: 1. scaffold: run `cargo generate-lockfile` after writing project files so every new project starts with a lockfile generated by the system cargo (which handles newer editions). 2. build: ensure_lockfile() runs before cargo build-sbf. It skips when Cargo.lock exists and is newer than Cargo.toml (zero overhead on normal builds). When the lockfile is missing or stale it regenerates with the system cargo. If regeneration fails and no lockfile exists at all, it exits with a diagnostic instead of letting build-sbf produce a confusing edition error. Closes #92
run_server() sets the TcpListener to non-blocking for idle timeout polling. Accepted TcpStreams inherit this flag. When serve_file() calls write_all() on a non-blocking socket and the kernel send buffer fills, write_all returns WouldBlock — silently discarded by the let _ = pattern. This truncates any response larger than one send buffer (~128-300KB). Fix: set_nonblocking(false) at the top of handle_connection so write_all blocks until all bytes are flushed. The blocking server (--diff mode) was never affected because serve_blocking() uses a blocking listener. Closes #94
⚡ CU Benchmark (Vault)
Binary size: 6,888 bytes (0 ⚪ bytes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #91, closes #92, closes #94
#91 — Init: validate target directory before prompting
scaffold()checked for conflicting files (existingQuasar.toml,Cargo.toml, non-empty directory) but only after the user had already answered every interactive prompt. Extracted the validation intovalidate_target_dir()and call it inrun()immediately after the project name is resolved — before toolchain, test language, template, and git prompts.#92 — Build:
toml_datetimeedition 2024 error with Solana toolchaincargo build-sbfuses Solana's bundled cargo (1.84), which cannot parse crate manifests that declareedition = "2024". Scaffolded projects had noCargo.lock, so Solana's cargo performed full dependency resolution and choked on transitive dev-dependencies liketoml_datetime >= 1.1.Two-layer fix:
Init time —
scaffold()now runscargo generate-lockfileafter writing project files, using the system cargo (which handles edition 2024). Every new project starts with a lockfile. If this fails (no network, etc.) it prints a note rather than aborting, since the project files are already on disk.Build time —
ensure_lockfile()runs beforecargo build-sbf. It comparesCargo.tomlandCargo.lockmtimes and skips entirely when the lockfile is already current (zero overhead on normal builds). When the lockfile is missing or stale it regenerates with the system cargo. If regeneration fails and no lockfile exists, it exits with a clear diagnostic pointing atrustup updateinstead of lettingbuild-sbfproduce a confusing edition error. If it fails but a stale lockfile exists, it warns and continues since the existing lockfile often still works.#94 — Profile flamegraph truncated for large JSON
run_server()sets theTcpListenerto non-blocking for idle-timeout polling. AcceptedTcpStreams inherit this flag. Whenserve_file()callswrite_all()on a non-blocking socket and the kernel send buffer fills (~128–300 KB),write_allreturnsWouldBlock— silently discarded by thelet _ =pattern. Any profile JSON larger than one send buffer was truncated, producingERR_CONTENT_LENGTH_MISMATCHin the browser.Fix:
set_nonblocking(false)at the top ofhandle_connection(). The blocking server (--diffmode viaserve_blocking()) was never affected because it uses a blocking listener.