serverless/serverless-python-requirements

Can't cache python requirements due to updated last modification time

dongho-jung opened this issue · 1 comments

as the title suggests, python requirements aren't being cached due to updated last modification time.

serverless-python-requirements can cache python requirements with lambda layer.
but in some cases, it can't.

I've investigated this issue for several days:

  • serverless says the hash of new pythonRequirements.zip is different with the hash of one in S3, so it should be uploaded again
  • however, when I compare all the files in local pythonRequirements.zip and S3 pythonRequirements.zip, their contents are all the same
  • finally found that, the last modification time of files is different..

this issue is mentioned before though, the problem is still exist.

In code, I think below snippet should fix this issue, but it couldn't its job.

// necessary to get the same hash when zipping the same content
date: new Date(0),

and I also found that it seems below snippet broke caching

// We'll "touch" the folder, as to bring it to the start of the FIFO cache
fse.utimesSync(workingReqsFolder, new Date(), new Date());

I don't know what the FIFO cache is in this context... but after I comment these lines out, the cache works like a charm.

please any comment on this. thanks

nevermind. I was using 5.1.1 and I updated to 5.4.0 and the issue is gone. sorry for inappropriate issue.