volta icon indicating copy to clipboard operation
volta copied to clipboard

Installation of nodejs does not work under proxies that require authorization.

Open ngicks opened this issue 10 months ago • 6 comments

Thank you for a great tool. I'm trying to manage Nodejs version under my personal environment with Volta but when I extend use of Volta to my work environment, it does not work because our company's cooporate proxy requires basic authentication. (The error was 407 Proxy Authentication Required.)

Quickly skimmed source codes, I found that attohttpc does not place Proxy-Authorization header for proxy CONNECT requests.

I'll raise an issue there too.

ngicks avatar Feb 25 '25 17:02 ngicks

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/comparing-module-system-configurations/59654/14

nixos-discourse avatar May 06 '25 15:05 nixos-discourse

With this change (or a variant of it), I tried running it on a nixosConfiguration and the evaluator OOM :(

fzakaria avatar May 06 '25 18:05 fzakaria

With this change (or a variant of it), I tried running it on a nixosConfiguration and the evaluator OOM :(

I've been there. Gotta take care to avoid infinite recursion.

mightyiam avatar May 06 '25 23:05 mightyiam

I wonder if this something max-call-depth can help us with. (CC @roberth)

Since now we have a way to deterministically replace "errors" with a fixed string; we can set an upper-bound and fail when we breach it.

Of course, this might not then solve the issue we sought to fix which was "a way to determine if someone sneaked in some nefarious NixOS options waiting to be enabled".

fzakaria avatar May 08 '25 00:05 fzakaria

Some infinite recursion are currently detectable by Nix. They're the kind that is trivial to detect (evaluating thunk x during evaluation of thunk x). Those are referred to as "black holes".

$ nix eval --json --expr 'let a = a; in a'
error: infinite recursion encountered
       at «string»:1:9:
            1| let a = a; in a
             |

But there's another kind, and that is the infinitely growing data structure.

$ nix eval --json --expr 'let a = {} // { inherit a;}; in a'
error: stack overflow (possible infinite recursion)

It is the latter kind that you are likely stumbled across. And I think there are not many of those. During Ocean Sprint 2025 the last of them may have been removed:

https://github.com/NixOS/nixpkgs/pull/390717

So, I think we don't need to support those.

mightyiam avatar May 09 '25 13:05 mightyiam

Interesting these have different outcomes when --json is presented and not.

nix eval --expr 'let a = {} // { inherit a;}; in a'
{ a = «repeated»; }

nix eval --json --expr 'let a = {} // { inherit a;}; in a'
error: stack overflow (possible infinite recursion)

We are building a demo file with some potential evaluation errors.

{
  missingAttr = let bar = { }; in bar.notExist;
  insideAList = [ (throw "a throw") ];
  deeper = { v = throw "v"; };
  failedAssertion = assert true; assert false; null;
  missingFile = builtins.readFile ./missing-file.txt;
  missingImport = import ./missing-import.nix;
  outOfBounds = builtins.elemAt [ 1 2 3 ] 100;
  failedCoersion = "${1}";
  failedAddition = 1.0 + "a string";
  unicodeError = throw "» injecttion: error: v»";
  repeatedRecursion = { a = let b = {inherit b;}; in b;};
}

Fails (obviously) pretty bad when --json is given but looks to be fine without it (I added newlines)

nix eval -f tests/functional/replace-eval-errors.nix
{
deeper = { v = «error: v»; };
failedAddition = «error: cannot add a string to a float»;
failedAssertion = «error: assertion 'false' failed»;
failedCoersion = «error: cannot coerce an integer to a string: 1»;
insideAList = [ «error: a throw» ];
missingAttr = «error: attribute 'notExist' missing»;
missingFile = «error: opening file '/home/fmzakari/code/github.com/NixOS/nix/tests/functional/missing-file.txt': No such file or directory»;
missingImport = «error: path '/home/fmzakari/code/github.com/NixOS/nix/tests/functional/missing-import.nix' does not exist»;
outOfBounds = «error: 'builtins.elemAt' called with index 100 on a list of size 3»;
repeatedRecursion = { a = { b = «repeated»; }; };
unicodeError = «error: » injecttion: error: v»»;
}

fzakaria avatar May 19 '25 04:05 fzakaria