Skip to content

RegisterResourceBuildTaskFactory is unusable under FiveM sandbox due to fs.write restrictions #3928

Description

@XenoS-ITA

What happened?

RegisterResourceBuildTaskFactory clearly exists to let resources run build steps (transpile, bundle, generate files, etc.). but in practice, you can't really use it because the sandbox blocks fs.write and similar by default, so you end up in this situation:

  • api is there for building stuff
  • building stuff needs file writes
  • sandbox blocks file writes

and so the api its just useless


Error you get:

Filesystem write permission check from 'X' for permission fs.write on resource '.../build/...' - write not allowed
Error: Access to this API has been restricted. Use --allow-fs-write to manage permissions.

the error tells you to use --allow-fs-write, but there's basically no documentation on how to actually use it


Another weird part:

there's already some cheats/workarounds in the runtime for tools like webpack/yarn:

if (m_resourceName == "yarn" || m_resourceName == "webpack")

so some tools get exceptions/special treatment


What would make more sense:
allow fs.write and similar when using build tasks or expose a way to enable write access globally

Expected result

RegisterResourceBuildTaskFactory should be usable out of the box for its intended purpose

Reproduction steps

  1. Create a basic resource and register a build task using RegisterResourceBuildTaskFactory
  2. Inside the build task, attempt to write a file to the resource folder (e.g. using fs.writeFileSync)
  3. Start the resource normally
  4. Start another resource using the build task and observe the error in the console

Importancy

Unknown

Area(s)

FXServer

Specific version(s)

FXServer-master SERVER v1.0.0.28009 win32

Additional information

No response

Metadata

Metadata

Assignees

Labels

bugtriageNeeds a preliminary assessment to determine the urgency and required action

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions