Hey there :slightly_smiling_face: [No unique ID f...
# help
d
Hey there šŸ™‚ [No unique ID for functions in
functions.jsonl
file.] [SST-version: 0.61.0] We are experiencing some weird behavior in the functions.jsonl file. Functions that are created with the same custom Construct are given the same ID in the
functions.jsonl
file. When calling the function, the source code in the
artifacts
is used where the ID is matched first. Example: We create functions in different services with the same custom CDK construct. Marked in the picture. The ID is the same ā€œb3f05295ā€. However, in the artifacts folder there is only the source code for ā€œ...services/user...ā€ for this ID. Expected behavior: Each function should get a unique ID in the
functions.jsonl
file. This way the same code will not be executed for each function. Does anyone else experience this problem?
@Fabian Ehringer
t
This maybe needs to be more sophisticated:
Copy code
const localId = crypto
      .createHash("sha1")
      .update(scope.node.id + id)
      .digest("hex")
      .substring(0, 8);
Think frank actually called it out at some point @Frank
f
is there a workaround? can we set the ID manually?
t
Can I see the code in your custom construct?
I'm confused how this can evaluate to the same
f
of course. I’m gonna send you the snippet as soon as I’m back on the computer
@thdxr That’s our custom construct for this lambda. We use this construct multiple times in our project, but in different stacks and with a different handler path. The class
acme.Stack
is just a wrapper of the
sst.Stack
to provide some ā€œmetadataā€ like the service domain to our constructs.
scope.node.id
in
sst.Function
is the id of the construct which is only unique in the parent construct, but neither in the stack nor in the app, right? Our custom construct is used multiple times with the same ID which is fine since it’s not the same stack. Using
scope.node.path
would fix it imo:
Copy code
const localId = crypto
      .createHash("sha1")
      .update(scope.node.path + id)
      .digest("hex")
      .substring(0, 8);
@thdxr @Frank Just fyi: I just tried this by changing that line in my node modules and it seems to work for me
t
I should probably be using node.addr
That's the mistake
path is interesting, what does that give you?
I'll fix this tonight
f
great. thanks a lot!
path is something like
<stage>-<projectName>-<stackId>/<constructId>
I don’t know what it would be for a nested/child stack with one or more constructs
d
thank you for your help @thdxr. šŸ˜‰ We have now patched version 0.61.0 with your changes. This fixes the problem. This also fixes the problem when we deployed the functions. As soon as a function was called that had one of the same Ids we always got the error - ERROR Uncaught Exception {ā€œerrorTypeā€: ā€œRuntime.ImportModuleErrorā€.....
t
Making the fix now
Took a bit to get all the tests working - just merged and released.