node-object-hash icon indicating copy to clipboard operation
node-object-hash copied to clipboard

Hasher generates different hashes every run for the same data

Open shadoworion opened this issue 1 year ago • 3 comments

Hasher generates different hashes every run for the same data.

It happens in AWS Lambda with docker images:

  1. public.ecr.aws/lambda/nodejs:20-arm64
  2. public.ecr.aws/lambda/nodejs:22-arm64

shadoworion avatar Nov 28 '24 08:11 shadoworion

Hi. Can you create minimal example to reproduce the issue?

SkeLLLa avatar Nov 28 '24 08:11 SkeLLLa

Hi. I have tried to create a minimal reproduction of this issue... It's very complicated. It looks like it happens when I have installed package (node-object-hash) in root package.json and also in sub-package:

  "dependencies": {
    "some-package": "0.0.1",
            ---->  "node-object-hash": "3.0.0"
    "node-object-hash": "3.0.0"
  },

Functions in this sub-package generate different hashes every run for the same data. It works when I remove the package (node-object-hash) from root package.json. And It happens only in aws lambda - it's weird.

I'll try to reproduce it, but I have a large project with many custom packages...

shadoworion avatar Nov 28 '24 10:11 shadoworion

And It happens only in aws lambda - it's weird.

Might be there's some issue with "minification" or whatever lambda could make under the hood. You can also try using not hasher, but just sort https://github.com/SkeLLLa/node-object-hash?tab=readme-ov-file#sortobject and log the results in order to see what's hashed.

SkeLLLa avatar Nov 28 '24 10:11 SkeLLLa