brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
690 stars 31 forks source link

config.telefuncFiles: Wrongly formatted path #90

Closed hagaigold closed 1 year ago

hagaigold commented 1 year ago

I tried the babel example from telefunc/examples/babel folder and had the following error:

 Debug info (this is for the Telefunc maintainers; you can ignore this): Wrongly formatted path: C:\CodeW\telefunc\examples\babel\hello.telefunc.mjs.
    at assertPosixPath (C:\CodeW\telefunc\telefunc\dist\cjs\utils\filesystemPathHandling.js:21:25)
    at isTelefuncFilePath (C:\CodeW\telefunc\telefunc\dist\cjs\utils\isTelefuncFilePath.js:7:50)
    at C:\CodeW\telefunc\telefunc\dist\cjs\node\server\serverConfig.js:48:69
    at Array.forEach (<anonymous>)
    at Object.validateUserConfig [as set] (C:\CodeW\telefunc\telefunc\dist\cjs\node\server\serverConfig.js:45:13)
    at file:///C:/CodeW/telefunc/examples/babel/server.mjs:10:24

Windows 10 Node.js v18.17.1

maybe windows related?

brillout commented 1 year ago

Fix pre-released in 0.1.60-commit-e16c585, can you confirm it's working now?

hagaigold commented 1 year ago

I see 2 more errors (the second error will be in the next comment):

fail on assertion- assert(filePath.startsWith('/')) in isTelefuncFilePath.ts I had a print of the filePath so the stack is +1 in line number below.

filePath   C:/CodeW/telefunc/examples/babel/hello.telefunc.mjs
node:internal/process/esm_loader:97
    internalBinding('errors').triggerUncaughtException(
                              ^

Error: [telefunc@0.1.60][Bug] You stumbled upon a bug in Telefunc's source code. Reach out at https://github.com/brillout/telefunc/issues/new or https://discord.com/invite/3DYWwk4xRQ and include this error stack (the error stack is usually enough to fix the problem). A maintainer will fix the bug (usually under 24 hours). Don't hesitate to reach out as it makes Telefunc more robust.
    at isTelefuncFilePath (C:\CodeW\telefunc\telefunc\dist\cjs\utils\isTelefuncFilePath.js:9:25)
    at C:\CodeW\telefunc\telefunc\dist\cjs\node\server\serverConfig.js:48:69
    at Array.forEach (<anonymous>)
    at Object.validateUserConfig [as set] (C:\CodeW\telefunc\telefunc\dist\cjs\node\server\serverConfig.js:45:13)
    at file:///C:/CodeW/telefunc/examples/babel/server.mjs:10:24
hagaigold commented 1 year ago

on windows fail to load the resolve .telefunc.mjs file:

Server running at http://localhost:3005                                                                                                                                                                        
filePath   C:/CodeW/telefunc/examples/babel/hello.telefunc.mjs                                                                                                                                                 
filePath   /hello.telefunc.mjs                                                                                                                                                                                 
filePath   /hello.telefunc.mjs                                                                                                                                                                                 
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
    at new NodeError (node:internal/errors:405:5)                                                                                                                                                              
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:131:11)                                                                                                                                     
    at defaultLoad (node:internal/modules/esm/load:82:3)                                                                                                                                                       
    at nextLoad (node:internal/modules/esm/loader:163:28)                                                                                                                                                      
    at ESMLoader.load (node:internal/modules/esm/loader:603:26)                                                                                                                                                
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)                                                                                                                                      
    at new ModuleJob (node:internal/modules/esm/module_job:64:26)                                                                                                                                              
    at #createModuleJob (node:internal/modules/esm/loader:480:17)                                                                                                                                              
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)                                                                                                                                        
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)                                                                                                                              
brillout commented 1 year ago

Alright, it should now be fixed as the CI now also runs /example/babel/ on Windows. Can you confirm? I'll then release the fixes.

hagaigold commented 1 year ago

fixed!

For the server-side:
Other than automatic TypeScript runtime validation, is there any other benefits using telefunc transformer over telefuncFiles?
While trying telefunc with DigitalOcean Functions (serverless), i found telefuncFiles a bit easier to setup.

brillout commented 1 year ago

It's also less bookkeeping.

Released as 0.1.61.