Skip to content

fix: transfer command with proxy support #23657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

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

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 added 2 commits June 20, 2025 14:11
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.`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant