diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-02-24 14:42:45 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-24 14:42:45 -0500 |
commit | 9aebc8bc19b1dfd9bce1789018f3f6b784175171 (patch) | |
tree | 760daa99df7479e34195a4339401a3f8f55c450e /test_util/src | |
parent | a27d0885f489f5640e38922fad8c8a1c49ae0aa4 (diff) |
fix: ensure concurrent non-statically analyzable dynamic imports do not sometimes fail (#17923)
Closes #17918
Diffstat (limited to 'test_util/src')
-rw-r--r-- | test_util/src/lib.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 4e97fee3b..2e053f85f 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -44,6 +44,7 @@ use std::sync::Mutex; use std::sync::MutexGuard; use std::task::Context; use std::task::Poll; +use std::time::Duration; use tokio::io::AsyncWriteExt; use tokio::net::TcpListener; use tokio::net::TcpStream; @@ -1058,6 +1059,20 @@ async fn main_server( return Ok(file_resp); } } + } else if let Some(suffix) = req.uri().path().strip_prefix("/deno_std/") { + let mut file_path = std_path(); + file_path.push(suffix); + if let Ok(file) = tokio::fs::read(&file_path).await { + let file_resp = custom_headers(req.uri().path(), file); + return Ok(file_resp); + } + } else if let Some(suffix) = req.uri().path().strip_prefix("/sleep/") { + let duration = suffix.parse::<u64>().unwrap(); + tokio::time::sleep(Duration::from_millis(duration)).await; + return Response::builder() + .status(StatusCode::OK) + .header("content-type", "application/typescript") + .body(Body::empty()); } Response::builder() |