Unverified Commit 834267b8 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Fix WASI trace imports and trace-store Clippy lint

Co-authored-by: 's avatarNiklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
parent 79529ba4
#[cfg(not(target_arch = "wasm32"))]
use std::thread;
use std::{ use std::{
borrow::Cow, borrow::Cow,
fs::{canonicalize, create_dir_all}, fs::{canonicalize, create_dir_all},
io::Write, io::Write,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::{Arc, LazyLock, Mutex}, sync::{Arc, LazyLock, Mutex},
thread,
time::{Duration, SystemTime}, time::{Duration, SystemTime},
}; };
...@@ -566,8 +567,10 @@ pub fn project_new<'env>( ...@@ -566,8 +567,10 @@ pub fn project_new<'env>(
.unwrap(); .unwrap();
}); });
let trace_server = std::env::var("NEXT_TURBOPACK_TRACE_SERVER").ok(); // The file/WebSocket trace server is native-only; the WASI binding
if trace_server.is_some() { // still supports writing traces, but cannot start a localhost server.
#[cfg(not(target_arch = "wasm32"))]
if std::env::var("NEXT_TURBOPACK_TRACE_SERVER").is_ok() {
thread::spawn(move || { thread::spawn(move || {
turbopack_trace_server::start_turbopack_trace_server(trace_file, None); turbopack_trace_server::start_turbopack_trace_server(trace_file, None);
}); });
......
use std::{path::PathBuf, sync::Arc}; #[cfg(not(target_arch = "wasm32"))]
use std::path::PathBuf;
use std::sync::Arc;
use napi_derive::napi; use napi_derive::napi;
#[cfg(not(target_arch = "wasm32"))]
use turbopack_trace_server::start_turbopack_trace_server;
use turbopack_trace_server::{ use turbopack_trace_server::{
QueryOptions, SortMode, query_spans, start_turbopack_trace_server, QueryOptions, SortMode, query_spans, store_container::StoreContainer,
store_container::StoreContainer,
}; };
/// An opaque handle to a running trace server instance. /// An opaque handle to a running trace server instance.
...@@ -87,6 +90,7 @@ pub struct TraceQueryResult { ...@@ -87,6 +90,7 @@ pub struct TraceQueryResult {
/// Starts the turbopack trace server on a background thread and returns a /// Starts the turbopack trace server on a background thread and returns a
/// handle immediately (non-blocking). The WebSocket server will be available /// handle immediately (non-blocking). The WebSocket server will be available
/// at `ws://127.0.0.1:<port>` (default port 5747). /// at `ws://127.0.0.1:<port>` (default port 5747).
#[cfg(not(target_arch = "wasm32"))]
#[napi] #[napi]
pub fn start_turbopack_trace_server_handle(path: String, port: Option<u16>) -> TraceServerHandle { pub fn start_turbopack_trace_server_handle(path: String, port: Option<u16>) -> TraceServerHandle {
let store = start_turbopack_trace_server(PathBuf::from(path), port); let store = start_turbopack_trace_server(PathBuf::from(path), port);
......
...@@ -75,19 +75,6 @@ impl Default for OutdatedSpans { ...@@ -75,19 +75,6 @@ impl Default for OutdatedSpans {
} }
} }
#[cfg(test)]
mod outdated_spans_tests {
use super::*;
#[test]
fn disabled_collector_does_not_retain_spans() {
let mut outdated = OutdatedSpans::with_capacity(8, false);
outdated.insert(SpanIndex::new(1).unwrap());
assert_eq!(outdated.iter().count(), 0);
}
}
pub struct Store { pub struct Store {
pub(crate) spans: ChunkedVec<Span>, pub(crate) spans: ChunkedVec<Span>,
pub(crate) self_time_tree: Option<SelfTimeTree<SpanIndex>>, pub(crate) self_time_tree: Option<SelfTimeTree<SpanIndex>>,
...@@ -553,3 +540,16 @@ impl Store { ...@@ -553,3 +540,16 @@ impl Store {
}) })
} }
} }
#[cfg(test)]
mod outdated_spans_tests {
use super::*;
#[test]
fn disabled_collector_does_not_retain_spans() {
let mut outdated = OutdatedSpans::with_capacity(8, false);
outdated.insert(SpanIndex::new(1).unwrap());
assert_eq!(outdated.iter().count(), 0);
}
}
...@@ -23,6 +23,7 @@ thread_local = { workspace = true } ...@@ -23,6 +23,7 @@ thread_local = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
tracing-subscriber = { workspace = true } tracing-subscriber = { workspace = true }
turbo-tasks-malloc = { workspace = true } turbo-tasks-malloc = { workspace = true }
tokio = { workspace = true, features = ["macros", "sync", "rt"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] [target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = ["macros", "signal", "sync", "rt"] } tokio = { workspace = true, features = ["signal"] }
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#![feature(arbitrary_self_types)] #![feature(arbitrary_self_types)]
#![feature(arbitrary_self_types_pointers)] #![feature(arbitrary_self_types_pointers)]
#[cfg(not(target_arch = "wasm32"))]
pub mod exit; pub mod exit;
pub mod filter_layer; pub mod filter_layer;
mod flavor; mod flavor;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment