[SalesForce] Stuck saving code

I have the following problem that happens from time to time:

When I am doing development in a Sandbox and try to save a change to an APEX class, the developer console never finishes saving. I can wait forever, and the title on the editor tab continues to say 'Saving…'.

If I close the editor, it shows me a popup window with the title FIELD_INTEGRITY_EXCEPTION and a message in Portuguese saying:

Failed to create deployment: Este contêiner está sendo salvo com deploymentId=1drZ0000001AMEs. Você não pode colocar uma solicitação na fila até que isso seja concluído.: ID do contêiner de metadados

My Salesforce is configured for Portuguese, and I don't have multilanguage licenses. Therefore, I'm stuck with poorly translated messages even in the developer tools. This makes it hard for me to search the web for possible solutions.

In English, the text of the message would mean something like this:

Failed to create deployment: This container is being saved with a deploymentId=1drZ0000001AMEs. You can't add a request to the queue until this is finished.: Metadata container ID

After the problem happens for the first time, I can never recover from it with the same user. Other users seem to continue being able to save code to the same sandbox.

In addition, after the first time, the problem persists even if I try to save code through an external tool like Mavensmate.

In my opinion, this is clearly a bug, but Salesforce's standard support plan doesn't even allow us to report bugs with developer tools.

For the meantime, I couldn't find any other solution but to delete the sandbox, create it again, and re-save all the code that I changed, class by class. Obviously this makes me waste a lot of time.

Best Answer

After many wasted hours, I found an unexplainable ritualistic solution.

It was mentioned as a small comment on another question.

The ritual is as follows:

  1. Cancel the endless 'saving' operation in the developer console. There's a context menu option to do this when you right click the title of the code editor tab.
  2. Delete the container by the Id mentioned in the popup error. This is done through the UI by going to a URL like https://<instance>.salesforce.com/<container id> and clicking the 'Delete' button.
  3. On the web UI, go to Setup > Develop > Apex Classes and find your class. Then click the 'Edit' button, which will open a page with a simpler code editor. Make your changes or paste the code you were trying to save on it, and then click 'Save'.
  4. Go back to the developer console and open the class you just saved. You should see the changes you made through the web UI there.
  5. Make another change and try to save it again through the developer console. The save operation should be working normally again.

It's important to notice that just deleting the container by its Id is not enough! The ritual must be completed in every detail! Apparently, saving the code through the Setup web UI is a vital step.

After all, I am certain that this is a bug. There's plenty of evidence to support this conclusion, but Salesforce chooses to not receive bug reports for their developer tools from anyone who doesn't have an expensive support plan.