Skip to content


Subversion checkout URL

You can clone with
Download ZIP


SystemStackError, stack level too deep #349

sonereker opened this Issue · 18 comments

With latest RVM, Ruby 1.9.2, delayed_job_active_record (0.3.2), Rails 3.2.0, pow (or webrick/thin);

I get "stack level too deep" error with notifier.

Notifier.delay(queue: "invitation").invitation(email, name)

Any suggestions?


I had the same error (also with ActionMailer, other jobs seemed to work). I experimented a bit and, although I don't know exactly why, it had to do with a require 'yaml' that was leftover in my config/boot.rb. Removing the line fixed the problem for me.



a config/initializer setup with content below breaks some (all?) .delay. method calls.

require 'yaml'
YAML::ENGINE.yamler = 'psych'

Error received is this (no further stack trace, that's it)

  SystemStackError (stack level too deep):
    actionpack (3.2.1) lib/action_dispatch/middleware/reloader.rb:70

Rails 3.2.1, Delayed Job 2.1.4 (last working one for me with Rails 3.2.1 at this time).


I had SystemStackError on mailers with rails 3.2.1, ruby 1.9.2p290 and delayed_job+delayed_job_mongoid. Upgrading to ruby 1.9.3p150 solved problem for me.


I'm getting the same error, but it doesn't seem to fail if I trie the identical steps in a rails console (on the same server). And I canot reproduce the error at all on a development OXS server with action mailer deliveries set to the same as the ubuntu staging server.

My configuration is RVM + Rails 3.2.0 + Passenger + Apache

The failing code looks like

@user =
# set various properties of the user

if try_save(@user)

The error is

SystemStackError (stack level too deep):
  activesupport (3.2.0) lib/active_support/callbacks.rb:409

Here's my RVM configuration


    uname:       "Linux 2.6.18-028stab099.3 #1 SMP Wed Mar 7 15:20:22 MSK 2012 x86_64 GNU/Linux"
    bash:        "/bin/bash => GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)"
    zsh:         " => not installed"

    version:      "rvm 1.10.2 by Wayne E. Seguin <>, Michal Papis <> []"
    updated:      "2 months 7 days 19 hours 35 minutes 29 seconds ago"

    interpreter:  "ruby"
    version:      "1.9.2p290"
    date:         "2011-07-09"
    platform:     "x86_64-linux"
    patchlevel:   "2011-07-09 revision 32553"
    full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]"

and relevant gem versions

  * rails (3.2.0)
  * delayed_job (3.0.1)
  * delayed_job_active_record (0.3.2)

After some digging around I noticed that the error is raised from


and the callstack shows ..

/shared/bundle/ruby/1.9.1/gems/delayed_job-3.0.1/lib/delayed/message_sending.rb:13:in `method_missing'
... # application code that invokes SomeMailer.delay.mail_method(with_params)

psych is indeed what is causing this. I'm still unclear on why this is happening only in one of my staging environments.

@mendable how did you resolve your issue? Did you actually find and remove a call to require 'yaml' as @pascalj suggested (above) or did you upgrade ruby to 1.9.3? Something else? Thanks in advance.


After upgrading to 1.9.3-p125 and rails 3.2.3, the problem no longer reproduces for me.


I am getting this error.

Upgraded to 1.9.3-p125 and rails 3.2.3 and I still have this error.


Quick fix: just add encode_with with empty method body for Mailer, that psych will know how to serialize Mailer class.

class Mailer
  def encode_with coder

Problem lines which hide this bug by 'stack too deep' in
so line with:

require File.expand_path('../psych_ext', __FILE__)

is never calls
but it's needed when to_yaml use psych engine as default.

UPD.: In my dependency was systemu, which reverting YAML engine to psych after DelayedJobs required with 'syck' engine, so yaml_ext works correctly, just my bad with my dependencies:

carrierwave_direct => uuid => macaddr => systemu.

I've been getting something similar, however its just with DelayedJob running without any jobs being started. I used DJ for custom jobs, but that is it. I did add a mailer around when this started, but I tried to remove the related files. I'm not sure if that was exactly what caused this to start or not for me. I had Daemon Spawn working nicely, then for some reason this started to happen. I'm trying to recall what gems I updated.

Using the following versions:
Ruby (1.9.3-p125)
Rails (3.2.3)
delayed_job (3.0.2)
delayed_job_active_record (0.3.2)
alexvollmer-daemon-spawn (0.2.0)

I was having issues with daemons gem (1.0.10 basically kept spawning new workers and was unable to kill off old ones, 1.1.0+ just constantly threw broken pipe errors that I couldn't resolve)

The only thing I can see in my delayed_job.log is

 script/delayed_job:18: stack level too deep (SystemStackError)

I had this error with the following two lines in boot.rb:

require "yaml"
YAML::ENGINE.yamler = "syck"

@pupeno please review my comment above. I have already described why this happen.


@kaeus you see

script/delayed_job:18: stack level too deep (SystemStackError)

because you tried to serialize Mailer object without encode_with method.


We met the same problem.That is because we have a enqueue method in our delayed job object.
After do into the source code ,we found this would cause an,rename it!


@bulanilly You + Google just saved me many many hours..


I had this issue recently when I rebuilt 1.9.2 with ssl. Upgrading to 1.9.3 worked, but does anybody know why?


+1 @pftg

Your answer worked for me. Thanks!!


Upgrading to 1.9.3 worked for me either.

@pawel2105 pawel2105 referenced this issue in collectiveidea/delayed_job_mongoid

Stack level too deep #21


On ruby-1.9.3-p392 and Rails 3.0.20 and delayed_job 3.0.5 the solution was @pftg's suggestion.

:+1: :dancer:

@allspiritseve allspiritseve referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@albus522 albus522 closed this

This should be written in bold:

If you have an #enqueue method in your job model, you'll get this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.