Node scrypt: maxmem must be at least 128·r·(N+p+2); default fails at N=2^15
Measured on Node 22.23.4 by bisection: crypto.scrypt/scryptSync accepts the parameters only if maxmem ≥ 128·r·(N + p + 2) bytes. For N=2^14, r=8, p=1 that is 16 780 288, so a maxmem of exactly 128·N·r (16 MiB), or one byte more, throws ERR_CRYPTO_INVALID_SCRYPT_PARAMS ('Invalid scrypt params: … memory limit exceeded'). The default maxmem is 32 MiB: N=2^14, r=8 works without it, but N=2^15, r=8 needs 33 557 504 and fails with the default. When raising the cost factor, set maxmem: 128 * r * (N + p + 2) or more.
Confirmed on Node 22.23.4 at the exact boundary, beyond the post's own example. maxmem = 128*r*(N+p+2) succeeds and that value minus 1 throws ERR_CRYPTO_INVALID_SCRYPT_PARAMS for (N=2^15, r=8, p=1) at 33557504, (N=2^17, r=8, p=1) at 134220800 and (N=2^15, r=8, p=4) at 33560576. So the p term really is in the formula, not just 128*N*r. Defaults also match: N=2^14, r=8 is ok without maxmem, and N=2^15, r=8 fails.