profile
viewpoint
Bartek Iwańczuk bartlomieju @straal Warsaw, PL Contributing to @denoland, developer at @straal, author of deno-postgres, interested in TypeScript, Rust and Python.

Pull request review commentdenoland/deno

fix: ModuleSpecifier resolution algo from cwd

 impl PartialEq<String> for ModuleSpecifier {     &self.to_string() == other   } }++#[cfg(test)]+mod tests {+  use super::*;++  #[test]+  fn test_resolve_from_cwd() {+    if cfg!(target_os = "windows") {+      let expected_url = "file:///C:/deno/tests/006_url_imports.ts";++      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        expected_url,+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:\deno\tests\006_url_imports.ts")+          .unwrap()+          .to_string(),+        expected_url,+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        expected_url+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"\tests\006_url_imports.ts")

You're right, probably using this bit should do the work

      let expected_url = format!(
        "file:///{}{}",
        cwd_string.as_str(),
        "tests/006_url_imports.ts"
      ).replace("\\", "/");
bartlomieju

comment created time in 2 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 0dab71d94936f600f82ec8823dd48c397ed45158

update TODOs

view details

push time in 3 hours

pull request commentdenoland/deno

fix: ModuleSpecifier resolution algo from cwd

@ry @piscisaureus please review

bartlomieju

comment created time in 3 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha fcd8a860c91e839a71de5a0ae59546d5408c2ceb

more fixes 2

view details

push time in 3 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha d079047f23459cbe00c36bb9777d88a93dd6ad0b

more fixes

view details

push time in 3 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 0dbdc32ff1e611c9c808403c6999b2182c10c7ca

more debugging

view details

push time in 4 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha ef0cbb24508e7a577b709ac7968d1d7a5a4e6adf

fix

view details

push time in 4 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 449246c45ef86242154fb9c9eb79781e318309fc

add more test cases for windows

view details

push time in 6 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 08e7578ae303b6cb5d8f9f825aee42c796fe64dd

add more test cases for windows

view details

push time in 6 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha ef849b125cbd246b36c53ba251d6666ca10f8224

use for worker specifier

view details

push time in 6 hours

issue commentdenoland/deno

Formatting issues when tsconfig file has unsupported compiler options

This issue should no longer occur now, that 3a4d88475b40a17f2ce17b775a3f07c78be83d79 landed

KluVerKamp

comment created time in 6 hours

delete branch bartlomieju/deno

delete branch : feat-shell_completion

delete time in 6 hours

startedmaxuuell/deno_init

started time in 6 hours

Pull request review commentdenoland/deno

fix: ModuleSpecifier resolution algo from cwd

 impl PartialEq<String> for ModuleSpecifier {     &self.to_string() == other   } }++#[cfg(test)]+mod tests {+  use super::*;++  #[test]+  fn test_absolute() {+    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:\deno\tests\006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+    } else {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd("/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///deno/tests/006_url_imports.ts",+      );+    }+  }++  #[test]+  fn test_relative() {+    // Assuming cwd is the deno repo root.+    let cwd = std::env::current_dir().unwrap();+    let cwd_string = String::from(cwd.to_str().unwrap()) + "/";+    let expected_url = format!(+      "file://{}{}",+      cwd_string.as_str(),+      "tests/006_url_imports.ts"+    ).replace("\\", "/");++    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"/tests/006_url_imports.ts")

Alright, thanks for explanation. I just installed Parallels, so I'll double check everything on my own

bartlomieju

comment created time in 10 hours

Pull request review commentdenoland/deno

fix: ModuleSpecifier resolution algo from cwd

 impl PartialEq<String> for ModuleSpecifier {     &self.to_string() == other   } }++#[cfg(test)]+mod tests {+  use super::*;++  #[test]+  fn test_absolute() {+    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:\deno\tests\006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+    } else {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd("/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///deno/tests/006_url_imports.ts",+      );+    }+  }++  #[test]+  fn test_relative() {+    // Assuming cwd is the deno repo root.+    let cwd = std::env::current_dir().unwrap();+    let cwd_string = String::from(cwd.to_str().unwrap()) + "/";+    let expected_url = format!(+      "file://{}{}",+      cwd_string.as_str(),+      "tests/006_url_imports.ts"+    ).replace("\\", "/");++    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"/tests/006_url_imports.ts")

Okay, tests suggests that it is actually absolute path:

---- module_specifier::tests::test_relative stdout ----
thread 'module_specifier::tests::test_relative' panicked at 'assertion failed: `(left == right)`
  left: `"file:///C:/tests/006_url_imports.ts"`,
 right: `"file://C:/deno/tests/006_url_imports.ts"`', ../../core\module_specifier.rs:153:7
bartlomieju

comment created time in 13 hours

Pull request review commentdenoland/deno

fix: ModuleSpecifier resolution algo from cwd

 impl PartialEq<String> for ModuleSpecifier {     &self.to_string() == other   } }++#[cfg(test)]+mod tests {+  use super::*;++  #[test]+  fn test_absolute() {+    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"C:\deno\tests\006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///C:/deno/tests/006_url_imports.ts",+      );+    } else {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd("/deno/tests/006_url_imports.ts")+          .unwrap()+          .to_string(),+        "file:///deno/tests/006_url_imports.ts",+      );+    }+  }++  #[test]+  fn test_relative() {+    // Assuming cwd is the deno repo root.+    let cwd = std::env::current_dir().unwrap();+    let cwd_string = String::from(cwd.to_str().unwrap()) + "/";+    let expected_url = format!(+      "file://{}{}",+      cwd_string.as_str(),+      "tests/006_url_imports.ts"+    ).replace("\\", "/");++    if cfg!(target_os = "windows") {+      assert_eq!(+        ModuleSpecifier::resolve_from_cwd(r"/tests/006_url_imports.ts")

TBH I'm not sure... according to comment you linked it is a relative path on windows.

bartlomieju

comment created time in 14 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 2ae86f205336d70eff32311438743eca482823a5

test normalization

view details

push time in 15 hours

pull request commentdenoland/deno

fix: run blocking function on a different task

@jcao219 could you sign CLA?

jcao219

comment created time in 16 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha df387d5c96ad72874a2d096f4c0807a7c7e9ff41

test normalization

view details

push time in 16 hours

issue commentdenoland/deno_std

suggestion: code style about async try catch

Not so long ago we had similar syntax to this example:

const [items, err] = await toDeno.readDir(dir));

It was deemed non-idiomatic TypeScript and I agree that try/catch is better.

Check #472 for more details.

Dreamacro

comment created time in 16 hours

pull request commentdenoland/deno

feat: deno completions command

@ry applied

bartlomieju

comment created time in 16 hours

issue commentdenoland/deno

installed programs should be able to take --reload argument

One problem, which we had with --help is what if a deno program wants to use that. What is the usecase (why would a user want to do this)?

To provide help/usage message for the program? Check deno_std/examples/cat.json

Is it easier/sufficient to do something like:

deno install --update catj https://deno.land/std/examples/catjson.ts --allow-read --refresh -L=info

The problem I have with this command (it was already prototyped in denoland/deno_std#512) is that you have to type full URL again - so actually it's the same as installing the program again. I'd be willing to settle on deno upgrade <exe>. This solution can be easily achieved by modifying script files - they just need to expose URL of the module.

How about supporting env variables for controlling those?

DENO_RELOAD=1 catj # => deno run --reload ...
DENO_DEBUG=1 catj # => deno run --debug ...

-1 for more env variables, let's figure out how to make flags work to our success.

Maybe we can hack clap? I don't like the bash solution.

I'm not sure, but on first sight I'd be pretty hard... I believe that bash solution is lowest hanging fruit. Another solution we might consider is using -- for script args:

$ deno install catj https://deno.land/std/examples/catjson.ts --allow-read
$ catj --reload -L=info -- file1.json file2.json // all args before `--` are passed directly to Deno
$ catj file1.json file2.json // no `--` - pass all args to script

This is still pretty esoteric... Let's look for reference in other implementations

ry

comment created time in 16 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 914b3dabe4b8842634dbef60b1b8b0f0cc5e3bb9

adjustments by @ry

view details

push time in 16 hours

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 898f8bb202d85af4e1ef4f8607734cf4add3bb96

test normalization

view details

push time in a day

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 270da0a691ada9b04f9206f8909fd6350dd8318c

fmt

view details

push time in a day

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 33638df5f1a7d41b437c7c120cff8bb7ddb7a0cb

test normalization

view details

push time in a day

issue commentdenoland/deno

installed programs should be able to take --reload argument

This is gonna be tricky... Clap (our CLI parser) doesn't support out use case, where we'd like to pass global flag after last argument (because after subcommand, rest of args is forwarded to script as Deno.args). Only solution that comes to my mind is hacking in bash/PowerShell to check for recognized Deno arguments in argument array (like -r/--reload) and passing them to deno instead of script.

Example (pseudo code)

if "-r" in $@
  $args = filter($@, i != "-r")
  deno --allow-read --reload https://deno.land/std/examples/catjson.ts $args
ry

comment created time in a day

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 0963553a7e2e81e73ccd63680a9f647282f1ac49

help, test, manual

view details

push time in a day

Pull request review commentdenoland/deno

feat: deno completions command

 To change installation directory use -d/--dir flag           // this is a fake subcommand - it's used in conjunction with           // AppSettings:AllowExternalSubcommand to treat it as an           // entry point script-          SubCommand::with_name("<script>").about("Script URL"),+          SubCommand::with_name("[SCRIPT]").about("Script URL"),         ),     ).subcommand(+      SubCommand::with_name("completions")+        .settings(&[+          AppSettings::DisableHelpSubcommand,

There is help, it's just disabling deno completions help command

bartlomieju

comment created time in a day

Pull request review commentdenoland/deno

feat: deno completions command

 pub fn flags_from_vec(       argv.extend(vec![source_file.to_string(), out_file.to_string()]);       DenoSubcommand::Bundle     }+    ("completions", Some(completions_match)) => {+      let shell: &str = completions_match.value_of("shell").unwrap();+      create_cli_app().gen_completions_to(+        "deno",+        Shell::from_str(shell).unwrap(),+        &mut std::io::stdout(),+      );+      std::process::exit(0);

I can add another DenoSubcommand and exit in main.rs

bartlomieju

comment created time in a day

PR opened denoland/deno

fix: ModuleSpecifier resolution algo from cwd

This PR is preparation work for #2572 - it turns out resolution algorithm was not working properly. It was giving wrong result for paths on Windows, eg.

C:\deno\tests\006_url_imports.ts 
// returned
C:\\deno\\tests\\006_url_imports.ts
// what should be returned
file:///C:/deno/tests/006_url_imports.ts

I renamed ModuleSpecifier::resolve_root to ModuleSpecifier::resolve_from_cwd so name is more appropriate, additionally added ModuleSpecifier::resolve_absolute.

This PR is focused mostly on Windows. CC @piscisaureus please take a look and suggest more test cases for Windows paths.

+122 -19

0 comment

6 changed files

pr created time in a day

create barnchbartlomieju/deno

branch : fix-module_specifier

created branch time in a day

Pull request review commentdenoland/deno

feat: deno completions command

 ability to spawn subprocesses.           // this is a fake subcommand - it's used in conjunction with           // AppSettings:AllowExternalSubcommand to treat it as an           // entry point script-          SubCommand::with_name("<script>").about("Script to run"),+          SubCommand::with_name("[SCRIPT]").about("Script to run"),

bash doesn't like < and > in completions, so changed that

bartlomieju

comment created time in a day

pull request commentdenoland/deno

feat: deno completions command

@ry this is now finished

bartlomieju

comment created time in a day

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha d29bf7cf7725389ebe48405b742808525118f7f1

finish completions command

view details

push time in a day

Pull request review commentdenoland/deno

WIP feat: deno completions command

 pub fn flags_from_vec(       argv.extend(vec![source_file.to_string(), out_file.to_string()]);       DenoSubcommand::Bundle     }+    ("completions", Some(_completions_match)) => {+      create_cli_app().gen_completions_to(+        "deno",+        Shell::Bash,+        &mut std::io::stdout(),+      );+      std::process::exit(1);

No reason, I was prototyping late at night and just copy pasted from other place... I'll ping you when it's ready for review

bartlomieju

comment created time in a day

issue commentdenoland/deno

Use forward slashes for paths on Windows

Closing this because @piscisaureus objects.

Could you elaborate? Does this block my idea to use forward slashes internally for DenoDir?

ry

comment created time in a day

issue commentdenoland/deno

Rename xeval?

Any update on this issue @ry?

ry

comment created time in a day

issue commentdenoland/deno

loading modules from HTTP sometimes results in multiple downloads

Fixed in #2477

ry

comment created time in a day

issue commentdenoland/deno

Don't assume paths are always valid UTF8

Reference: #2572 and #2559

piscisaureus

comment created time in a day

issue commentdenoland/deno

Use forward slashes for paths on Windows

Reference: #2572 - that PR should ensure that

ry

comment created time in a day

issue commentdenoland/deno

Cache miss when running in container

This issue was resolved, see comment.

I suppose we can close this issue now, CC @ry

snobu

comment created time in a day

issue commentdenoland/deno

Split flatbuffers messages into Requests and Responses

Close in favor of #2121?

CC @ry

ry

comment created time in a day

issue commentdenoland/deno

print JS stack unexpected signal like ctrl+c

@mhvsa are you working on this issue?

ry

comment created time in a day

issue commentdenoland/deno

Issue importing external library

Import map support is available in Deno starting with v0.9.0 I suppose we can close this issue.

CC @ry

ddibiase

comment created time in a day

PR opened denoland/deno

WIP feat: deno completions command
+24 -4

0 comment

1 changed file

pr created time in 2 days

create barnchbartlomieju/deno

branch : feat-shell_completion

created branch time in 2 days

push eventbartlomieju/deno

Matt Harrison

commit sha 20f41e719d2cb5add8e9168d00f239843fd56d31

Fix comment (#2555)

view details

andy finch

commit sha eb93dc58a11d9e9a295eff31f9c2c6a3a4c5170b

add encodeInto to TextEncoder (#2558)

view details

Bartek Iwańczuk

commit sha 642eaf97c67c6070935a2977014c743ba59deff8

feat: redirect process stdio to file (#2554)

view details

Yoshiya Hinosawa

commit sha 201ddd29a7908d457ed43b030476707d32848868

fmt_test: resolve old absolute path issue (#2562)

view details

Yoshiya Hinosawa

commit sha 988bcbb8842d12202f278808698a6b546718e764

fetch: make body async iterable (#2563)

view details

Bartek Iwańczuk

commit sha b9fbd552149c1fe61b662c9b1a1ed1b42e5487ae

feat: log permission access (#2518) Replaces -D/--log-debug flag with --log-level=debug --log-level=info displays permission access

view details

Gurwinder Singh

commit sha 6fa6828e5f0f7abac20ec342ee5ec57654a425d0

Minor tweaks (#2569) 1. Separate Snapshot and Script StartupData functions based on cfg "no-snapshot-init" 2. Replace deprecated Once::ONCE_INIT with Once::new (https://github.com/rust-lang/rust/pull/61757) 3. Elide lifetime 4. Fix typos

view details

JaePil Jung

commit sha d82089ca358b7fa4d5e2b7a357f651364643de7a

Update manual.md (#2571)

view details

Long(Tony) Lian

commit sha 1d0d54247c0a5a69207f8e0b948d3b60287467eb

feat: fetch() now handles redirects (#2561)

view details

Bartek Iwańczuk

commit sha 3c81cca0374c96ff4759ec9305eb5529dd29a4d8

fix: prevent multiple downloads of modules (#2477)

view details

Bartek Iwańczuk

commit sha 70a9859adce478180a15d43877fe239a44379556

refactor: use Path/PathBuf in deno dir (#2559)

view details

Bartek Iwańczuk

commit sha 81933a3ff83d604f7c14e06bc9bb410ffaf3b7a1

start refactor to use Url in deno_dir

view details

Bartek Iwańczuk

commit sha 1a2d375e302f4e00369e4a5c7aecdf21ca07837a

use Url in get_source_code_async

view details

Bartek Iwańczuk

commit sha c1220ab672eaffdce6110400665bb8eeef872175

use Url in fetch_local_source

view details

Bartek Iwańczuk

commit sha 4d52cc4748ee2743282afffd3b2ead2cacc0d5e4

fix for tests

view details

Bartek Iwańczuk

commit sha 4c33072bbbdc639121ee9ed42f6f3289b3c71a9b

short-circuit for SourceMapGetter is not valid URL

view details

Bartek Iwańczuk

commit sha 63bc05c79a28ecc0608717697d772de3504321d0

debug AppVeyor

view details

Bartek Iwańczuk

commit sha e9efe590292aac48a3183dafa10d1ba2a6b360bb

more debugging

view details

push time in 2 days

delete branch bartlomieju/deno

delete branch : feat-concrete_types_in_deno_dir

delete time in 2 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 70a9859adce478180a15d43877fe239a44379556

refactor: use Path/PathBuf in deno dir (#2559)

view details

push time in 2 days

pull request commentdenoland/deno

refactor: use Path/PathBuf in deno dir

@ry merged

bartlomieju

comment created time in 2 days

push eventbartlomieju/deno

Matt Harrison

commit sha 20f41e719d2cb5add8e9168d00f239843fd56d31

Fix comment (#2555)

view details

andy finch

commit sha eb93dc58a11d9e9a295eff31f9c2c6a3a4c5170b

add encodeInto to TextEncoder (#2558)

view details

Bartek Iwańczuk

commit sha 642eaf97c67c6070935a2977014c743ba59deff8

feat: redirect process stdio to file (#2554)

view details

Yoshiya Hinosawa

commit sha 201ddd29a7908d457ed43b030476707d32848868

fmt_test: resolve old absolute path issue (#2562)

view details

Yoshiya Hinosawa

commit sha 988bcbb8842d12202f278808698a6b546718e764

fetch: make body async iterable (#2563)

view details

Bartek Iwańczuk

commit sha b9fbd552149c1fe61b662c9b1a1ed1b42e5487ae

feat: log permission access (#2518) Replaces -D/--log-debug flag with --log-level=debug --log-level=info displays permission access

view details

Gurwinder Singh

commit sha 6fa6828e5f0f7abac20ec342ee5ec57654a425d0

Minor tweaks (#2569) 1. Separate Snapshot and Script StartupData functions based on cfg "no-snapshot-init" 2. Replace deprecated Once::ONCE_INIT with Once::new (https://github.com/rust-lang/rust/pull/61757) 3. Elide lifetime 4. Fix typos

view details

JaePil Jung

commit sha d82089ca358b7fa4d5e2b7a357f651364643de7a

Update manual.md (#2571)

view details

Long(Tony) Lian

commit sha 1d0d54247c0a5a69207f8e0b948d3b60287467eb

feat: fetch() now handles redirects (#2561)

view details

Bartek Iwańczuk

commit sha 3c81cca0374c96ff4759ec9305eb5529dd29a4d8

fix: prevent multiple downloads of modules (#2477)

view details

Bartek Iwańczuk

commit sha 2c12b23b7d8a7a7daca0d7ca49229a1616b1680d

Merge branch 'master' into feat-concrete_types_in_deno_dir

view details

push time in 2 days

push eventbartlomieju/deno

Matt Harrison

commit sha 20f41e719d2cb5add8e9168d00f239843fd56d31

Fix comment (#2555)

view details

andy finch

commit sha eb93dc58a11d9e9a295eff31f9c2c6a3a4c5170b

add encodeInto to TextEncoder (#2558)

view details

Bartek Iwańczuk

commit sha 642eaf97c67c6070935a2977014c743ba59deff8

feat: redirect process stdio to file (#2554)

view details

Yoshiya Hinosawa

commit sha 201ddd29a7908d457ed43b030476707d32848868

fmt_test: resolve old absolute path issue (#2562)

view details

Yoshiya Hinosawa

commit sha 988bcbb8842d12202f278808698a6b546718e764

fetch: make body async iterable (#2563)

view details

Bartek Iwańczuk

commit sha b9fbd552149c1fe61b662c9b1a1ed1b42e5487ae

feat: log permission access (#2518) Replaces -D/--log-debug flag with --log-level=debug --log-level=info displays permission access

view details

Gurwinder Singh

commit sha 6fa6828e5f0f7abac20ec342ee5ec57654a425d0

Minor tweaks (#2569) 1. Separate Snapshot and Script StartupData functions based on cfg "no-snapshot-init" 2. Replace deprecated Once::ONCE_INIT with Once::new (https://github.com/rust-lang/rust/pull/61757) 3. Elide lifetime 4. Fix typos

view details

JaePil Jung

commit sha d82089ca358b7fa4d5e2b7a357f651364643de7a

Update manual.md (#2571)

view details

Long(Tony) Lian

commit sha 1d0d54247c0a5a69207f8e0b948d3b60287467eb

feat: fetch() now handles redirects (#2561)

view details

Bartek Iwańczuk

commit sha 3c81cca0374c96ff4759ec9305eb5529dd29a4d8

fix: prevent multiple downloads of modules (#2477)

view details

push time in 2 days

delete branch bartlomieju/deno

delete branch : test-prevent_multiple_downloads

delete time in 2 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha c9ffdbc098bda12fedcebd7725dea29071f614c9

reset CI

view details

push time in 2 days

Pull request review commentdenoland/deno

refactor: use Path/PathBuf in deno dir

 use std::str; use url; use url::Url; +fn normalize_path(path: &Path) -> PathBuf {

I believe it does... PTAL at this comment.

I'd prefer to normalize all paths to use forwards slashes everywhere in our codebase.

bartlomieju

comment created time in 2 days

Pull request review commentdenoland/deno

fix: prevent multiple downloads of same file

 mod tests {     });   } +  #[test]+  fn test_get_source_code_multiple_downloads_of_same_file() {+    let (_temp_dir, deno_dir) = test_setup();+    // http_util::fetch_sync_string requires tokio+    tokio_util::init(|| {+      let module_name = "http://localhost:4545/tests/subdir/mismatch_ext.ts";+      let filename = deno_fs::normalize_path(+        deno_dir+          .deps_http+          .join("localhost_PORT4545/tests/subdir/mismatch_ext.ts")+          .as_ref(),+      );+      let headers_file_name = source_code_headers_filename(&filename);++      // first download+      let result =+        get_source_code(&deno_dir, module_name, &filename, false, false);+      assert!(result.is_ok());++      let result = fs::File::open(&headers_file_name);+      assert!(result.is_ok());+      let headers_file = result.unwrap();+      // save modified timestamp for headers file+      let headers_file_metadata = headers_file.metadata().unwrap();+      let headers_file_modified = headers_file_metadata.modified().unwrap();++      // download file again, it should use already fetched file even though `use_cache` is set to+      // false, this can be verified using source header file creation timestamp (should be+      // the same as after first download)+      let result =+        get_source_code(&deno_dir, module_name, &filename, false, false);+      assert!(result.is_ok());++      let result = fs::File::open(&headers_file_name);+      assert!(result.is_ok());+      let headers_file_2 = result.unwrap();+      // save modified timestamp for headers file+      let headers_file_metadata_2 = headers_file_2.metadata().unwrap();+      let headers_file_modified_2 = headers_file_metadata_2.modified().unwrap();++      assert_eq!(headers_file_modified, headers_file_modified_2);

Very nice! I've been trying to come up with a test for this failure for a long time. I have verified this test does indeed fail when applied to master.

Thank you for solving this bug!

Great, thanks! :tada:

bartlomieju

comment created time in 2 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha e693ce13607d0864a2e4e7db374336a27653eff7

address review

view details

push time in 2 days

Pull request review commentdenoland/deno

fix: prevent multiple downloads of same file

 fn fetch_remote_source_async(         match fetch_once_result {           FetchOnceResult::Redirect(url) => {             // If redirects, update module_name and filename for next looped call.-            let resolve_result = dir-              .resolve_module(&(url.to_string()), ".")-              .map_err(DenoError::from);-            match resolve_result {-              Ok((new_module_name, new_filename)) => {-                if maybe_initial_module_name.is_none() {-                  maybe_initial_module_name = Some(module_name.clone());-                  maybe_initial_filename = Some(filename.clone());-                }-                // Not yet completed. Follow the redirect and loop.-                Ok(Loop::Continue((-                  dir,-                  maybe_initial_module_name,-                  maybe_initial_filename,-                  new_module_name,-                  new_filename,-                )))-              }-              Err(e) => Err(e),+            let (new_module_name, new_filename) = dir+              .resolve_module(&(url.to_string()), ".")?;

Nope, url is of type http::uri::Uri it doesn't have as_str method. This was addressed in #2559

bartlomieju

comment created time in 2 days

Pull request review commentdenoland/deno

fix: prevent multiple downloads of same file

 fn filter_shebang(bytes: Vec<u8>) -> Vec<u8> {   } } +fn save_code_and_headers(+  filename: &str,+  module_name: &str,+  source: &str,+  maybe_content_type: Option<String>,+  maybe_initial_filename: Option<String>,+) -> Result<(), DenoError> {+  let p = PathBuf::from(filename);+  match p.parent() {+    Some(ref parent) => fs::create_dir_all(parent),+    None => Ok(()),+  }?;+  // Write file and create .headers.json for the file.+  deno_fs::write_file(&p, &source, 0o666)?;+  {+    save_source_code_headers(filename, maybe_content_type.clone(), None);

save_code_and_headers and save_source_code_headers are too similarly named.

Agreed, will rename

bartlomieju

comment created time in 2 days

pull request commentdenoland/deno

WIP refactor: use Url in deno dir

Note to self: our current resolving of paths (including ModuleSpecifier::resolve_root) is not 100% correct.

These specifiers are not resolved properly on windows:

// 1.
C:\deno\tests\006_url_imports.ts 
// result URL 
C:\\deno\\tests\\006_url_imports.ts
// expected URL
file:///C:/deno/tests/006_url_imports.ts

// this one fails completely
\deno\tests\006_url_imports.ts

Consider using NormalizedPath instead of Path that leverages normalize_path from deno_dir.rs - this will ensure that all paths passed around our code base use / (forward slash) instead of mixing forward and backward slashes. This is fine, because fs module can handle forward slashes on Windows.

bartlomieju

comment created time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 4e2008e96efa0c92ace4c0f35083ede8664a4057

more debugging

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha d52d870af5ebc3490193f25426d574779226750e

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha b23c9713982cccdef7a8b467e3e0fb840858f78e

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 5dcdb5ac249bbcd3c2d4393913f7965bd03fd55e

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 0efb1ff126fdc16d697ff19db41ace1869308cc5

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 3ea2ade1766aa9a6952e2883749af74c0239d832

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 9f23837e41349524327cb09f72f827e85ff3ab70

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 35b86cefd80003ea7846cd10058d3be32cc5ed7a

debug AppVeyor

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 3eed33d53e16825d2243a0e2d9beedce35a7ee7e

short-circuit for SourceMapGetter is not valid URL

view details

push time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 3277830d5c3636420a3aeaf73c173ad9279a8c78

reset CI

view details

push time in 3 days

Pull request review commentdenoland/deno

WIP refactor: use Url in deno dir

 impl SourceMapGetter for DenoDir {   }    fn get_source_line(&self, script_name: &str, line: usize) -> Option<String> {-    match self.fetch_module_meta_data(script_name, ".", true, true) {+    // TODO(bartlomieju): this is temporary hack to make tests pass+    // TODO: this method shouldn't issue `fetch_module_meta_data` - this is done for each line

Reference: https://github.com/denoland/deno/commit/425df50484f315dcd63b4d93ab6911702779899e#comments

bartlomieju

comment created time in 3 days

CommitCommentEvent

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 81098b531774189b6df76c9c97e56ccb3a1e895d

use Url in get_source_code_async

view details

Bartek Iwańczuk

commit sha d78e4545e407c1d364df4d26350a200399e854dd

use Url in fetch_local_source

view details

Bartek Iwańczuk

commit sha 8a4558ac96dc36c354f6ae01417cc3ae1833254c

fix for tests

view details

push time in 3 days

PR opened denoland/deno

WIP refactor: use Url in deno dir

Follow-up to #2559 (and blocked by it)

Use Url instead of String for specifiers in //cli/deno_dir.rs

+352 -385

0 comment

9 changed files

pr created time in 3 days

create barnchbartlomieju/deno

branch : refactor-use_url_in_deno_dir

created branch time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha f36dcaae9d2e271ce345d3431e4774430106a994

use PathBuf in ModuleMetaData

view details

push time in 3 days

pull request commentdenoland/deno

fix: run blocking function on a different task

@jcao219 🙏 kudos!

I had exactly same problem working on #2535, where using timeouts with workers froze everything.

jcao219

comment created time in 3 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha e5d5acda367e8188e80b53a0053a0159ba31db5f

lint clippy

view details

push time in 4 days

pull request commentdenoland/deno

WIP feat: use concrete types in deno dir

CC @kitsonk

bartlomieju

comment created time in 4 days

pull request commentdenoland/deno

prevent multiple downloads of same file [do not merge]

@ry I think I managed to find solution using initial approach that involves marking which URLs had already been downloaded. It's much simpler compared to saving whole response.

I changed two tests to behave like a real world scenario and added a test for multiple downloads (verifying that headers file modified timestamp is unchanged). Let me know what you think.

But as you said earlier this is definitely to be rewritten from ground up.

bartlomieju

comment created time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 4bdc3f24c522e162ad624c35ffd97c110d9fb636

tests for multiple downloads

view details

Bartek Iwańczuk

commit sha d14adf2bdeb49bf9f01db4340bde09b9c7471045

rename FetchSet to DownloadCache

view details

push time in 4 days

pull request commentdenoland/deno

WIP feat: use concrete types in deno dir

@ry please review - I'd rather do specifier refactor to Url in followup PR - this one is pretty convoluted already. Additionally there's #2477 that you said you wanted to put in next release and that would cause a lot of conflicts during rebase.

bartlomieju

comment created time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 10b774bf678aa37adcc0517d56bf8a8199ed48af

change signature of fetch_module_meta_data

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 72c340786087965d314d0e826463ab50a68d0491

fix resolve_from_cwd for real

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 4f8493ba7323e70bd4f711c599a91d5426abb048

fix resolve_from_cwd

view details

push time in 4 days

delete branch bartlomieju/deno

delete branch : feat-log_perm_access

delete time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 446195a4e6c3495e2d2546014c4ea587232d90b7

fix emoji

view details

push time in 4 days

Pull request review commentdenoland/deno

WIP feat: use concrete types in deno dir

 impl DenoDir {   // https://github.com/denoland/deno/blob/golang/deno_dir.go#L32-L35   pub fn cache_path(     self: &Self,-    filename: &str,+    filepath: &Path,     source_code: &[u8],   ) -> (PathBuf, PathBuf) {     let cache_key =-      source_code_hash(filename, source_code, version::DENO, &self.config);+      source_code_hash(filepath, source_code, version::DENO, &self.config);     (       self.gen.join(cache_key.to_string() + ".js"),       self.gen.join(cache_key.to_string() + ".js.map"),     )   } -  pub fn code_cache(-    self: &Self,-    module_meta_data: &ModuleMetaData,-  ) -> std::io::Result<()> {-    let (cache_path, source_map_path) = self-      .cache_path(&module_meta_data.filename, &module_meta_data.source_code);-    // TODO(ry) This is a race condition w.r.t to exists() -- probably should-    // create the file in exclusive mode. A worry is what might happen is there-    // are two processes and one reads the cache file while the other is in the-    // midst of writing it.-    if cache_path.exists() && source_map_path.exists() {-      Ok(())-    } else {-      match &module_meta_data.maybe_output_code {-        Some(output_code) => fs::write(cache_path, output_code),-        _ => Ok(()),-      }?;-      match &module_meta_data.maybe_source_map {-        Some(source_map) => fs::write(source_map_path, source_map),-        _ => Ok(()),-      }?;-      Ok(())-    }-  }-   pub fn fetch_module_meta_data_async(

Looking at current usage of fetch_module_meta_data_async (and fetch_module_meta_data) I'm considering dropping referrer argument - besides op_fetch_module_meta_data it is always "." and the only place it's useful is in the error message:

Cannot resolve module "file:///some/file.ts" from "."
Cannot resolve module "file:///some/other/file.ts" from "file:///some/file.ts"
// would become
Cannot resolve module "file:///some/file.ts"
Cannot resolve module "file:///some/other/file.ts"

Since specifier should already be resolved I believe using referrer is redundant - you request local or remote file via absolute path and cache acts like a black box giving it back. This change would bring us closer to refactoring DenoDir into actual cache.

CC @ry

bartlomieju

comment created time in 4 days

pull request commentdenoland/deno

WIP feat: use concrete types in deno dir

@ry PTAL if this direction is satisfactory. Handling of paths was replaced with use of PathBuf/Path. Now I'll tackle specifiers and referrers in deno_dir and change them to Url

bartlomieju

comment created time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha ba58178c43907a1ba3aaaa87021eec8df87c46ba

replace resolve_path with resolve_from_cwd

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 7220a0ab69f1b9fe43dc2dac83683b43a30fdb16

remove -D/--log-debug flag

view details

Bartek Iwańczuk

commit sha 3e9476888df12a7e39f62db6d7d441a5e4a7e4f0

factor out permission emoji to constant

view details

push time in 4 days

Pull request review commentdenoland/deno

feat: log permission access

 To get help on the another subcommands (run in this case):    deno help run")     .arg(+      Arg::with_name("log-level")+        .short("L")+        .long("log-level")+        .help("Set log level")+        .takes_value(true)+        .possible_values(&["debug", "info"])+        .global(true),+    ).arg(       Arg::with_name("log-debug")

We can, but then for debug you have to go with -L=debug, are you fine with that?

bartlomieju

comment created time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha c14d678e9b309004220703bf575ed6b5fe5a71d1

start replacing resolve_path with resolve_from_cwd

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 6d7d393c45743aa90aca2b1b00444faf77bc64dd

remove code_cache unused function

view details

Bartek Iwańczuk

commit sha 6fda85ad1740e43c7531ec15a8965cfaa8a8d02c

clippy lint

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 51bc2e654f2ca625b8680ea2654d6ee27ecdf5c0

fix

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 93632d2c278acaa9efe83191e0ec8e3d97049314

use only Path in deno_dir.rs

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 8dc018062164bac14659bfa76e8330471dd63066

normalize_path, replace PathBuf

view details

push time in 4 days

push eventbartlomieju/deno

Bartek Iwańczuk

commit sha 4eabee4f9cc586c4a25a5530fbf3c86f0943d765

use Path in cache ops

view details

Bartek Iwańczuk

commit sha 06003c49710eeded7632393e85bdf5d4d1d358aa

Revert "introduce ModuleSpecifier to deno_dir" This reverts commit 2efca8ff4c50ed92235476a556e0311a866f1a5e.

view details

Bartek Iwańczuk

commit sha 66b8dd47dbd1016170f724a704873258b523bd28

fix text

view details

push time in 4 days

delete branch bartlomieju/deno_std

delete branch : feat-add_catjson

delete time in 5 days

more