Skip to content

Conversation

@dhoko
Copy link
Contributor

@dhoko dhoko commented Jun 3, 2025

Hello 👋

What does it do?

The current version of the command is unable to run inside a CI env with a proxy.

ex:

> strapi transfer --from https://xxxx/admin --exclude files --from-token [MASKED] --force --verbose
? The transfer will delete all the local Strapi assets and its database. Are you sure you want to proceed? Yes
Config file not loaded, extension must be one of .js,.json): admin.js.map
Config file not loaded, extension must be one of .js,.json): api.js.map
Config file not loaded, extension must be one of .js,.json): database.js.map
Config file not loaded, extension must be one of .js,.json): features.js.map
Config file not loaded, extension must be one of .js,.json): middlewares.js.map
Config file not loaded, extension must be one of .js,.json): plugins.js.map
Config file not loaded, extension must be one of .js,.json): server.js.map
[2025-06-03 09:56:57.796] info: [remote-source-provider] establishing websocket connection
[2025-06-03 09:56:57.799] info: [local-destination-provider] validating options
[2025-06-03 09:56:58.314] info: [local-destination-provider] Rolling back transaction
[2025-06-03 09:56:58.315] info: [local-destination-provider] Rolled back transaction
Transfer process failed.

That's it, nothing else.

Why is it needed?

So we can execute the command inside an env with a proxy, ex a CI job.

How to test it?

Set a proxy, run the transfer it fails. Fixed via sed inside my CI to validate everything.
I also added to my env GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE: '' cf https://www.npmjs.com/package/global-agent#what-is-the-reason-global-agentbootstrap-does-not-use-http_proxy

Now when it fails we will hav a few more informations:

ProviderTransferError
    at WebSocket.<anonymous> (/builds/web/cms/node_modules/@strapi/data-transfer/dist/strapi/providers/utils.js:158:20)
    at Object.onceWrapper (node:events:639:26)
    at WebSocket.emit (node:events:524:28)
    at WebSocket.emit (node:domain:489:12)
    at emitErrorAndClose (/builds/web/cms/node_modules/ws/lib/websocket.js:1035:13)
    at ClientRequest.<anonymous> (/builds/web/cms/node_modules/ws/lib/websocket.js:880:5)
    at ClientRequest.emit (node:events:524:28)
    at ClientRequest.emit (node:domain:489:12)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5) {
  origin: 'provider',
  severity: 'fatal',
  details: { step: 'transfer', details: { details: [Object] } }
}
{ details: { error: '' } }
Transfer process failed.

To validate it, I have a job inside my CI to execute the command. Before calling it I added:

    - |
      sed -i  "s/await strapi.telemetry.send('didDEITSProcessFail/console.log('MJS');console.error(e);console.error(e?.details?.details);\nawait strapi.telemetry.send('didDEITSProcessFail/"  node_modules/@strapi/strapi/dist/src/cli/commands/transfer/action.mjs

    - |
      sed -i  "s/await strapi.telemetry.send('didDEITSProcessFail/console.error(e);console.log('JS');console.error(e?.details?.details);\nawait strapi.telemetry.send('didDEITSProcessFail/"  node_modules/@strapi/strapi/dist/src/cli/commands/transfer/action.js

    - |
      sed -i  "1i require('global-agent/bootstrap');\n"  node_modules/@strapi/strapi/dist/src/cli/commands/transfer/action.js

    - |
      sed -i  "1i import 'global-agent/bootstrap';\n\n"  node_modules/@strapi/strapi/dist/src/cli/commands/transfer/action.mjs

Related issue(s)/PR(s)

#22755
strapi/documentation#2514

@vercel
Copy link

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
contributor-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2025 9:00am

@dhoko dhoko changed the title Fix transfer command with proxy fix: transfer command with proxy Jun 3, 2025
@dhoko dhoko force-pushed the fix/transfer-command branch from 220e230 to ae85be3 Compare June 3, 2025 16:10
@dhoko dhoko changed the title fix: transfer command with proxy fix: transfer command with proxy support Jun 3, 2025
@dhoko dhoko force-pushed the fix/transfer-command branch from 0a7c9c7 to 5f40f32 Compare June 4, 2025 08:29
@dhoko dhoko force-pushed the fix/transfer-command branch 3 times, most recently from 8e9fe89 to 24d6037 Compare June 4, 2025 08:49
@dhoko dhoko force-pushed the fix/transfer-command branch from 7735ff1 to f45d930 Compare June 4, 2025 14:34
@dhoko dhoko force-pushed the fix/transfer-command branch from f45d930 to 8c6ad6b Compare June 5, 2025 07:54
@dhoko dhoko force-pushed the fix/transfer-command branch from 8c6ad6b to 2df6a32 Compare June 10, 2025 09:20
@dhoko dhoko force-pushed the fix/transfer-command branch from 2df6a32 to 3f4a9dc Compare June 13, 2025 13:49
@dhoko dhoko force-pushed the fix/transfer-command branch from 3f4a9dc to c658e34 Compare June 20, 2025 12:11
@vercel
Copy link

vercel bot commented Oct 28, 2025

@Bassel17 is attempting to deploy a commit to the Strapi Team on Vercel.

A member of the Team first needs to authorize it.

@Bassel17 Bassel17 self-requested a review October 28, 2025 16:22
@Bassel17 Bassel17 added pr: fix This PR is fixing a bug source: core:strapi Source is core/strapi package labels Oct 28, 2025
@Bassel17
Copy link
Member

Hello thank you for this PR,
I have a small question for you, can you confirm for me how you setup strapi to use your proxy ?
did you pass it in the strapi server config as such

proxy: {
    global:'your_proxy'
  },

@dhoko
Copy link
Contributor Author

dhoko commented Oct 29, 2025

Nope we don't have this inside the config.

dhoko added 2 commits October 29, 2025 16:27
log errors when the transfer task faill

ex error we will be able to see when we run the transfer task:

console.error(e)
```
ProviderTransferError
    at WebSocket.<anonymous> (/builds/web/cms/node_modules/
    @strapi/data-transfer/dist/strapi/providers/utils.js:158:20)
    at Object.onceWrapper (node:events:639:26)
    at WebSocket.emit (node:events:524:28)
    at WebSocket.emit (node:domain:489:12)
    at emitErrorAndClose (/builds/web/cms/node_modules/ws/lib/
    websocket.js:1035:13)
    at ClientRequest.<anonymous> (/builds/web/cms/node_modules/
    ws/lib/websocket.js:880:5)
    at ClientRequest.emit (node:events:524:28)
    at ClientRequest.emit (node:domain:489:12)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5) {
  origin: 'provider',
  severity: 'fatal',
  details: { step: 'transfer', details: { details: [Object] } }
}
```

console.error(e.details.details)
```
{ details: { error: '' } }
````

And the default error message we used to see: `Transfer process failed.`
@dhoko dhoko force-pushed the fix/transfer-command branch from 8c5c120 to 84cb65b Compare October 29, 2025 15:27
@Bassel17
Copy link
Member

okay thanks, I would encourage to setup the config with the proxy
https://docs.strapi.io/cms/configurations/server
that should make the transfer work with a proxy.
I'll still look into your PR and see if it's something we want to implement.

@Bassel17
Copy link
Member

Bassel17 commented Nov 7, 2025

Thanks for the time effort but I don't think we will with this solution,
in the meantime you can configure the proxy as I mentioned above

@Bassel17 Bassel17 closed this Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: fix This PR is fixing a bug source: core:strapi Source is core/strapi package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants