LiquidPlayer / LiquidCore

Node.js virtual machine for Android and iOS
MIT License
1.01k stars 127 forks source link

MicroService fails to run if path to js file is too long #190

Open maugf214 opened 3 years ago

maugf214 commented 3 years ago

I first discovered this bug when using flutter_liquidcore, but I think the underlying issue is in this library. You can reproduce the bug by creating a new iOS project following the instructions in the README for LiquidCore and by giving the application a very long name.

The app will crash with the error "NSUnderlyingError=0x60000221cd80 {Error Domain=NSPOSIXErrorDomain Code=63 "File name too long"}}" when calling [self fetchService]; in LCMicroService.m.

I think this is due to the full path being URL encoded and then stored as the serviceId. The serviceId is then used as a single component of a path later on. There is a limit of 256 characters per path component so this throws an exception.

Another side effect of basing the serviceId on the path to the .js file is that this path will be different each time the app is run, due to the way that iOS sandboxes applications. This means that files are created but never cleaned up.

I have managed to fix the problem locally by hard coding the serviceId. I also had to make minor changes to fetchService() to ensure that the previous .js files are always deleted before being overwritten (apparently fileExistsAtPath() is not fully reliable).

I'm happy to raise a PR with my changes but I don't think hard coding the ServiceId is the right solution.