Cannot push BalenaSound, 'Cannot set headers after they are sent to the client'

Hello, I am following BalenaSound project and can’t seem to push balena-sound-master files to my device.

After successfully logging in with balena-cli, unzipping balena-sound-master and cd’ing into its folder, I use :

balena push application-name

After adding debug 1 , this is the output:

Debug: original argv0="balena" argv=[/home/mal/balena-cli/balena,/snapshot/versioned-source/bin/balena,push,XXXXXXXXXXX] length=4
[debug] Using . as build source
[debug] Connecting to builder at https://builder.balena-cloud.com/v3/build?owner=gh_XXXXXXX&app=XXXXXXXXX&dockerfilePath=&emulated=false&nocache=false&headless=false
| Uploading source package to balena cloud[debug] received HTTP 200 OK
[debug] handling message: {"type":"metadata","resource":"buildLogId","value":1020819}
[debug] handling message: {"message":"\u001b[31m[Error]\u001b[39m    An error occured: Cannot set headers after they are sent to the client","isError":true}
[Error]    An error occured: Cannot set headers after they are sent to the client
[debug] handling message: {"message":"\u001b[31m[Error]\u001b[39m    Not deploying release.","isError":true}
[Error]    Not deploying release.
RemoteBuildFailedError: Remote build failed
    at Bluebird.then (/snapshot/versioned-source/build/utils/remote-build.js:56:23)
    at tryCatcher (/snapshot/versioned-source/node_modules/bluebird/js/release/util.js:16:23)
    at Promise.module.exports.Promise._settlePromiseFromHandler (/snapshot/versioned-source/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise.module.exports.Promise._settlePromise (/snapshot/versioned-source/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise.module.exports.Promise._settlePromise0 (/snapshot/versioned-source/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise.module.exports.Promise._settlePromises (/snapshot/versioned-source/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/snapshot/versioned-source/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/snapshot/versioned-source/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/snapshot/versioned-source/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/snapshot/versioned-source/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
    at process.topLevelDomainCallback (domain.js:120:23)

If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/

Note I edited out possibly sensible info as user and device name.

Thank you!

Hi @mal . Are you trying to push to a localMode development device or to balenaCLoud app on the cloud?
For the former you need to do:

balena push devicename.local

When pushing on the local network directly to the device, you need to have the .local to allow the local IP resolution to find the device.

For the latter you need to do:

balena push myAppName

I am trying to push to application-name on the balenaCloud app.

I just edited that part of my post as I had written device-name, sorry.

The pasted output corresponds to

balena push app-name

Balena cli works well btw. I can list apps and devices etc. And this device and app is up, listed and running well.

But I can’t push, nope.

Thank you @shaunmulligan

Cool, thanks for the info. I will try reproduce on my side. Can you give me some detail about your laptop OS, the CLI version you are using and how you installed the CLI?

OS: Linux Mint 19.1 Tessa x86_64
DE: Cinnamon 4.0.10

Balena CLI: 11.7.5

The Cli I’ve just downloaded, unzipped and added to PATH. Then I successfully logged in with ‘balena login’

Is there anything else I can provide you with?

Oh, btw, as suggested during the balena sound tutorial, the ISO I downloaded had developer mode enable.

Thank you @shaunmulligan

Thanks @mal that should be good for now.

Thank you,

May I ask when may it be that you people take a look at it and answer? Of course this is a public tutorial and I am not expecting (free) premium support, just asking.

Thanks again

I am actually working on reproducing it now, so we will see if I hit the same issue and then go from there. I assume this is the first time you are pushing code to balena right?

That is correct, I just signed up, burned your iso using your etcher. Then followed instructions for balena cli, etc.

So first time everything.

I saw in the dashboard I can provide your people access to the device, let me know if you need that.

Thank you

May not be relevant, but I just tried to push using sudo, same error.

Thanks

Hi @mal , I recreated your issue, it seems we introduced a bug in the latest version of the CLI. If you install v11.7.4 it should work correctly.

A-há!

Oook, I’ll do that and report back

Thank you

            \
		     \
		      \\
		       \\
		        >\/7
		    _.-(6'  \
		   (=___._/` \
		        )  \ |
		       /   / |
		      /    > /
		     j    < _\
		 _.-' :      ``.
		 \ r=._\        `.
		<`\\_  \         .`-.
		 \ r-7  `-. ._  ' .  `\
		  \`,      `-.`7  7)   )
		   \/         \|  \'  / `-._
		              ||    .'
		               \\  (
		                >\  >
		            ,.-' >.'
		           <.'_.''
		             <'

Great stuff @mal

@shaunmulligan thanks again

I’ve just reached balena because of this project, now that it is running (quite well ) I am wondering about balena in general.

I haven’t used Docker yet. I am wondering, can I actually install regular linux packages/apps into a Docker container and run them alongside this bluetooth receiver project via SSH?

I’ve ssh’ed into the rpi from the dashboard, apt-get is not there.

Feel free to direct me to docs or make me open a new thread.
Thanks

Hi @mal , I would recommend starting from https://www.balena.io/docs/learn/getting-started/raspberrypi3/nodejs/ . You can install regular package in the container, to install these you would add them to your Dockerfile.template (think of it a recipe that builds the userspace) . You can also test install from ssh in the container but i think you would need to run apt-get update && apt-get install wget , but note that anything installed via SSH at run time will not persist or be saved to the image. you need to install things via Dockerfile to make them reproducible and persistent.

1 Like

FYI, with regard to the issue with CLI version 11.7.5 (which required you to install v11.7.4), I understand the issue was actually with the backend (image builders) rather than the CLI, and it has been fixed. Using the latest CLI version should now be OK.