Workers 500 Internal Server Error when doing `puter.fs.write` on relative path
https://rey-hello.puter.work
The code
router.get('/', async ({request}) => {
await me.puter.fs.write("test.txt", "hi");
return 'Hello World'; // returns a string
});
Result
But having the route absolute at either of these will work
-
/<name>/test.txt -
~/test.txt
so i think it's because of the relative path
Another thing, for my original code of having just test.txt i'm not sure where it will be created, but naturally I would expect it to be the same directory from where I have my worker code in
#1710 will fix the 500 response and give a more appropriate 400 response which will call this an "unresolved relative path" and suggest that the user has to specify an absolute path.
Right now puter.js is responsible for resolving relative paths but that's only a thing for apps (in the case of apps, it's the appdata directory). What would me.puter in a worker have as it's "working directory"? I don't think we've discussed this before. If it's the developers home directory that could get messy - maybe workers need a directory for this.
Right now puter.js is responsible for resolving relative paths but that's only a thing for apps (in the case of apps, it's the appdata directory).
That makes sense
What would me.puter in a worker have as it's "working directory"?
I think another idea we could explore is the worker current working directory, so it's not necessarily home, so if i create worker in say /username/workers/hello/worker.js, all the files will be under /username/workers/hello/
I like the idea above, barring security issues we should probably do this for workers
#1710 will fix the 500 response and give a more appropriate 400 response which will call this an "unresolved relative path" and suggest that the user has to specify an absolute path.
Right now
puter.jsis responsible for resolving relative paths but that's only a thing for apps (in the case of apps, it's the appdata directory). What wouldme.puterin a worker have as it's "working directory"? I don't think we've discussed this before. If it's the developers home directory that could get messy - maybe workers need a directory for this.
Since me.puter is godmode by default I guess there is no such thing as a default cwd
any issue with having the worker's dirname as the path I cprefix to the filename to prevent this from happening?
there isn't really a worker dirname by default currently. Frontend can specify an app context to run the worker as but the current behavior is god mode so it runs in the root level context, not really as an app at all, it doesn't really have a home