Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Continuation of node fs polyfill with directory support #4087

Merged
merged 21 commits into from Mar 3, 2020

Conversation

cknight
Copy link
Contributor

@cknight cknight commented Feb 23, 2020

Continuation of the work for the fs polyfill in support of #3403. Specifically this adds internal implementations of the directory classes used in node and exported by yet to be implemented Deno fs polyfill methods fs.opendir(), fs.opendirSync(), or fsPromises.opendir().

@cknight
Copy link
Contributor Author

cknight commented Feb 23, 2020

Seems I've been caught out by the move to 'use strict' and a stale version of the VS Code plugin. I'll work through the issues raised.

@cknight
Copy link
Contributor Author

cknight commented Feb 23, 2020

@ry Any idea why the windows CI is failing with access denied issues for my new tests (using Deno.open()) while the ubuntu and macOS CI builds pass? I've not got a windows machine to test on.

Example failing output:

FAILED Closing current directory with callback is successful
PermissionDenied: Access is denied. (os error 5)
    at Object.constructError ($deno$/errors.ts:39:13)
    at unwrapResponse ($deno$/dispatch_json.ts:40:12)
    at Object.sendAsync ($deno$/dispatch_json.ts:91:10)
    at async Object.open ($deno$/files.ts:81:15)
    at async Object.fn (_fs_dir_test.ts:31:33)
    at async Object.runTests ($deno$/testing.ts:157:7)
    at async runTestModules (runner.ts:234:3)
    at async main (runner.ts:276:5)

Failing test for above output, failing on Deno.open(".") line:

test({
  name: "Closing current directory with callback is successful",
  async fn() {
    const fileInfo: Deno.File = await Deno.open(".");
    assert(Deno.resources()[fileInfo.rid]);
    let calledBack = false;
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    new Dir(fileInfo.rid, ".").close((valOrErr: any) => {
      assert(!valOrErr);
      calledBack = true;
    });
    assert(calledBack);
    assert(!Deno.resources()[fileInfo.rid]);
  }
});

These failures occur for both reading the current directory, e.g. . as above, and for a directory created by Deno.makeTempDirSync() in subsequent tests.

Also, as an aside, neither my VS Code nor tools/lint.py picked up on the new strict typescript rules. Running the cargo tests was the only way to discover these issues. Any ideas on how to get the new stricter rules showing in VS Code?

@ry
Copy link
Member

ry commented Feb 24, 2020

Any idea why the windows CI is failing with access denied issues for my new tests

Not sure...

Also, as an aside, neither my VS Code nor tools/lint.py picked up on the new strict typescript rules. Running the cargo tests was the only way to discover these issues. Any ideas on how to get the new stricter rules showing in VS Code?

I'm not sure but I think VS Code / ESLint probably sniff for tsconfig.json and assumes non-strict when it doesn't find it. Maybe @kitsonk can give more clues.

@cknight
Copy link
Contributor Author

cknight commented Feb 24, 2020

OK, no worries, I'll dig around deeper and also take latest master as I'm seeing other reports of CI failures on Windows, maybe related.

@kitsonk
Copy link
Contributor

kitsonk commented Feb 24, 2020

I'm not sure but I think VS Code / ESLint probably sniff for tsconfig.json and assumes non-strict when it doesn't find it. Maybe @kitsonk can give more clues.

It would be up to whatever plugin to determine what to configure the language service yet. If it is @axetroy plugin, then I don't know if he has defaulted to strict mode now under Deno.

@axetroy
Copy link
Contributor

axetroy commented Feb 24, 2020

Yes, if you enable the axetroy.vscode-deno extension, strict mode is enabled by default

https://github.com/axetroy/vscode-deno/blob/6ec1cb401f852ce71f3ebdb3e6fefe36d254d0b1/typescript-deno-plugin/src/plugin.ts#L18-L33

  private readonly DEFAULT_OPTIONS: ts_module.CompilerOptions = {
    allowJs: true,
    checkJs: false,
    strict: true,
    esModuleInterop: true,
    jsx: this.typescript.JsxEmit.React,
    module: this.typescript.ModuleKind.ESNext,
    moduleResolution: this.typescript.ModuleResolutionKind.NodeJs,
    outDir: "$deno$",
    resolveJsonModule: true,
    sourceMap: true,
    stripComments: true,
    target: this.typescript.ScriptTarget.ESNext,
    noEmit: true,
    noEmitHelpers: true
  };

@cknight cknight mentioned this pull request Feb 24, 2020
@cknight
Copy link
Contributor Author

cknight commented Feb 24, 2020

Thanks both. I'm using the axetroy plugin, so will see if I can reproduce the missing strict behaviour I was seeing earlier and raise an issue if found.

@ecyrbe
Copy link
Contributor

ecyrbe commented Feb 24, 2020

hi again, this one seems missing in your implementation :

@cknight
Copy link
Contributor Author

cknight commented Feb 24, 2020

Ah, nice spot, thanks. It was actually there, but under a different name while I was testing something. Now renamed as it should.

@cknight
Copy link
Contributor Author

cknight commented Feb 26, 2020

Well, that was a touch harder than I anticipated, but every day is a learning day :) Now ready for review.

@cknight
Copy link
Contributor Author

cknight commented Feb 28, 2020

@ry - This is now ready for review.

std/node/_fs_dir.ts Outdated Show resolved Hide resolved
@cknight
Copy link
Contributor Author

cknight commented Mar 1, 2020

@ry - ready for review again. In the general, should I tag you (and/or others?) on pull requests ready for review? There's absolutely no rush with this one, but I'm unclear what the best process is once a PR is ready for review. Let me know what's best. Thanks!

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just one comment...

(And yes, tagging me is a good way to get a review - sorry for the delay)

std/node/_fs_dir.ts Outdated Show resolved Hide resolved
@cknight
Copy link
Contributor Author

cknight commented Mar 2, 2020

@ry link added and now ready for review again

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ry ry merged commit 3968308 into denoland:master Mar 3, 2020
@cknight cknight deleted the fsPolyfillApi branch March 3, 2020 22:42
dubiousjim added a commit to dubiousjim/deno that referenced this pull request Mar 5, 2020
* denoland/master: (22 commits)
  fix event target tests
  Support async function and EventListenerObject as listeners (denoland#4240)
  Allow BadResource errors to take a custom message (denoland#4251)
  Document TypeScript compiler options (denoland#4241)
  refactor: preliminary cleanup of Deno.runTests() (denoland#4237)
  refactor: cleanup compiler runtimes (denoland#4230)
  Use discord instead of gitter (denoland#4253)
  Remove unnecessary macro from cli/ops/tty.rs (denoland#4254)
  Remove Deno.errors.Other (denoland#4249)
  refactor: rewrite testPerm into unitTest (denoland#4231)
  Migrate internal bundles to System (denoland#4233)
  Fix inlining of lib.dom.iterable.d.ts. (denoland#4242)
  Fix `deno install` file name including extra dot on Windows (denoland#4243)
  assert build success for test plugin (denoland#4223)
  Disable flaky and broken tests (denoland#4239)
  add assertOps sanitizer in cli/js/ unit tests (denoland#4209)
  misc: reduce unnecesarry output in cli/js tests (denoland#4182)
  feat(std/node): add directory classes (denoland#4087)
  Do not convert exceptions to JSON and back (denoland#4214)
  Don't reset exception handle after calling ErrWithV8Handle::get_handle() (denoland#4214)
  ...
mhvsa pushed a commit to mhvsa/deno that referenced this pull request Mar 6, 2020
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 21, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 24, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Jan 31, 2021
caspervonb pushed a commit to caspervonb/deno_std that referenced this pull request Feb 1, 2021
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.

None yet

5 participants