Serverless Function: "File not found"

Hey! I try to just update a field with "Total Contract Value" that is just a commitment*amount but the flow is crashing with "File not found" error... Any help is pretty welcomed! thanks!
No description
No description
35 Replies
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
Hi @Absynth, could you check devtools if there's any meaningful message? I've tried your case with code below and it works
export const main = async (params: {
a: number;
b: number;
}): Promise<object> => {
const { a, b } = params;

let result = a * b;

return {"test":result};
};
export const main = async (params: {
a: number;
b: number;
}): Promise<object> => {
const { a, b } = params;

let result = a * b;

return {"test":result};
};
No description
Absynth
AbsynthOP4w ago
Thanks for your answer! the problem is not in the test that is also working on my end, but in the fact that when I launch the workflow, it's never working :/. I have not found meaningful message in the console, but I can try to find one. If I look at the console when modifing the opportunity to trigger, it does not give much...
No description
No description
No description
No description
Absynth
AbsynthOP4w ago
No description
ɃØĦɆᵾS
ɃØĦɆᵾS4w ago
That's weird, I don't see a reason why this shouldn't work, are you self-hosted by any chance? If so, could you check if there's any useful related log? Also, could you send the state of workflow from last run?
Absynth
AbsynthOP3w ago
Yes sorry I'm self hosted on railway. Last version 1.2.1 You are right, this is what I just got in the Worker's logs (by just activating the workflow)
[
FileStorageException [Error]: File not found
at LocalDriver.copy (/app/packages/twenty-server/dist/src/engine/core-modules/file-storage/drivers/local.driver.js:114:23)
at async ServerlessFunctionService.publishOneServerlessFunctionOrFail (/app/packages/twenty-server/dist/src/engine/metadata-modules/serverless-function/serverless-function.service.js:142:9)
at async WorkflowStatusesUpdateJob.handlePublishServerlessFunction (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:105:48)
at async WorkflowStatusesUpdateJob.handleWorkflowVersionStatusUpdated (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:136:9)
at async Promise.all (index 0)
at async WorkflowStatusesUpdateJob.handle (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:62:17)
at async MessageQueueExplorer.invokeProcessMethods (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:113:17)
at async MessageQueueExplorer.handleProcessor (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:104:13)
at async /app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:79:17
at async Worker.processFn (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/drivers/bullmq.driver.js:41:13) {
code: 'FILE_NOT_FOUND',
userFriendlyMessage: undefined
}
]
[
FileStorageException [Error]: File not found
at LocalDriver.copy (/app/packages/twenty-server/dist/src/engine/core-modules/file-storage/drivers/local.driver.js:114:23)
at async ServerlessFunctionService.publishOneServerlessFunctionOrFail (/app/packages/twenty-server/dist/src/engine/metadata-modules/serverless-function/serverless-function.service.js:142:9)
at async WorkflowStatusesUpdateJob.handlePublishServerlessFunction (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:105:48)
at async WorkflowStatusesUpdateJob.handleWorkflowVersionStatusUpdated (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:136:9)
at async Promise.all (index 0)
at async WorkflowStatusesUpdateJob.handle (/app/packages/twenty-server/dist/src/modules/workflow/workflow-status/jobs/workflow-statuses-update.job.js:62:17)
at async MessageQueueExplorer.invokeProcessMethods (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:113:17)
at async MessageQueueExplorer.handleProcessor (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:104:13)
at async /app/packages/twenty-server/dist/src/engine/core-modules/message-queue/message-queue.explorer.js:79:17
at async Worker.processFn (/app/packages/twenty-server/dist/src/engine/core-modules/message-queue/drivers/bullmq.driver.js:41:13) {
code: 'FILE_NOT_FOUND',
userFriendlyMessage: undefined
}
]
I created a full new workflow and did the same thing with the snippet you sent, still the same result
Absynth
AbsynthOP3w ago
I don't know if it's normal, but in the files it seems that the serverless function is in a draft folder
No description
No description
Absynth
AbsynthOP3w ago
No description
No description
ɃØĦɆᵾS
ɃØĦɆᵾS3w ago
@Prastoin could you please take a look? My knowledge about inner workings of workflow is limited in this case
Prastoin
Prastoin3w ago
@thomast could you please have a look to this when you have some free time ?
thomast
thomast3w ago
@martmull
martmull
martmull3w ago
@Absynth Workflows are run by the server when you use test, but when you launch it, workflow are run by the worker. Worker and server must share the same localStorage memory for workflows to run properly. If not, worker can't access code step code file and fails to run them. You need to use an s3 like storage system We mentioned that in the doc, albeit somewhat discreetly https://twenty.com/developers/section/self-hosting/docker-compose#persistence As you are self hosting on Railway, their is something you can use, give me 2s to find it
Absynth
AbsynthOP3w ago
Yes sorry I'm self hosted on railway. Last version 1.2.1
https://railway.com/deploy/nAL3hA @thomasmol fyi
Railway
Deploy Twenty CRM
Deploy Twenty CRM on Railway with one click, start for free. Deploy latest version of Twenty CRM (v1.*) on Railway
martmull
martmull3w ago
yes, I have updated my message after checking history my bad 😅
Absynth
AbsynthOP3w ago
no prob, thanks for helping!
martmull
martmull3w ago
Railway
Deploy MinIO
Deploy MinIO on Railway with one click, start for free. Open source object storage with an S3 compatible API
Absynth
AbsynthOP3w ago
hum... I already have minIO in the template I use
martmull
martmull3w ago
ok all you workflow with code step cause the same issue?
Absynth
AbsynthOP3w ago
No description
Absynth
AbsynthOP3w ago
never succeded into making them work indeed.
martmull
martmull3w ago
Ok when looking at the picture you provide, I don't see a direct link from twenty worker to Bucket. Also, what is this link between twenty worker and twenty (I assume twenty is server)?
Absynth
AbsynthOP3w ago
the links are done automatically when a ressource is used by another service if I'm correct. Like if they share secrets Would it be as easy as adding the right secrets to the worker, or is it a bit more complex? (just asking, if it's the case.. that would be great)
martmull
martmull3w ago
I think it is just that, I would try that at first 🤞
thomasmol
thomasmol3w ago
yea i think you can just add the env vars related to the storage to the worker service as well?
Absynth
AbsynthOP3w ago
hey @thomasmol ! thanks for joining (sorry for the "summon" but the template being yours... it might be interesting for you!). you mean all those?
No description
martmull
martmull3w ago
maybe STORAGE_TYPE too
thomasmol
thomasmol3w ago
yes STORAGE_TYPE and this one
Absynth
AbsynthOP3w ago
let's go, I'll test right away and tell you
Absynth
AbsynthOP3w ago
oooh it worked - workflow status that was glitchy is now active as intended - the workflow did run successfully. Well done guys! @thomasmol is the modification I've done steady or do you need to update your template? @martmull , @ɃØĦɆᵾS @thomasmol ( @thomast and @Prastoin too) you have my thanks!
No description
thomasmol
thomasmol3w ago
ahh very cool
martmull
martmull3w ago
Great! Pleased to see it works
ɃØĦɆᵾS
ɃØĦɆᵾS3w ago
Happy to see your issue resolved!
thomasmol
thomasmol3w ago
@Absynth yea i'll update the template description with info about setting up S3 for this. I think Railway is working on making the storage volumes accessible from multiple services, but right now that is not possible. So you'd have to use some type of S3 compatible storage for this
Absynth
AbsynthOP3w ago
no prob for me! my question was more: will the next deployment "touch/change" the secrets in the worker?
thomasmol
thomasmol3w ago
i am actually not sure template updates are done automatically like that. I hope it doesn't, because it could break deployments for others?
Absynth
AbsynthOP3w ago
you are totally right! Hopefully only the new ones will be impacted 😆

Did you find this page helpful?