LogController fails to poll after some update

Nextcloud version (eg, 29.0.5): 29.0.4
Operating system and version (eg, Ubuntu 24.04): Ubuntu 22.04.4 LTS
Apache or nginx version (eg, Apache 2.4.25): nginx/1.25.2 (Ubuntu)
PHP version (eg, 8.3): PHP 8.1.2-1ubuntu2.18

The issue you are facing:
When browing the log via /admin/logging, log entries seem to load correctly.
However, after a few seconds a popup message is shown stating “Neue Einträge konnten nicht abgerufen werden.” (could not fetch new entries).
The log file shows multiple messages that look like this:

{"reqId":"gcFB6Yzf34GnQbf03qYj","level":3,"time":"2024-05-22T23:57:10+02:00","remoteAddr":"REDACTED","user":"nc-admin","app":"index","method":"GET","url":"/apps/logreader/api/poll?lastReqId=MIrK0trXG79ncKvZuYKc","message":"OCA\\LogReader\\Controller\\LogController::poll(): Argument nextcloud/server#1 ($lastReqId) must be of type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 232 in file '/var/www/nextcloud/apps/logreader/lib/Controller/LogController.php' line 102","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0","version":"29.0.0.19","exception":{"Exception":"Exception","Message":"OCA\\LogReader\\Controller\\LogController::poll(): Argument nextcloud/server#1 ($lastReqId) must be of type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 232 in file '/var/www/nextcloud/apps/logreader/lib/Controller/LogController.php' line 102","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":338,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1050,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":49,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","Line":170,"Previous":{"Exception":"TypeError","Message":"OCA\\LogReader\\Controller\\LogController::poll(): Argument nextcloud/server#1 ($lastReqId) must be of type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 232","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":232,"function":"poll","class":"OCA\\LogReader\\Controller\\LogController","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php","line":138,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/App.php","line":184,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Route/Router.php","line":338,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":1050,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"/var/www/nextcloud/index.php","line":49,"function":"handleRequest","class":"OC","type":"::"}],"File":"/var/www/nextcloud/apps/logreader/lib/Controller/LogController.php","Line":102},"message":"OCA\\LogReader\\Controller\\LogController::poll(): Argument nextcloud/server#1 ($lastReqId) must be of type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 232 in file '/var/www/nextcloud/apps/logreader/lib/Controller/LogController.php' line 102","exception":{},"CustomMessage":"OCA\\LogReader\\Controller\\LogController::poll(): Argument nextcloud/server#1 ($lastReqId) must be of type string, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 232 in file '/var/www/nextcloud/apps/logreader/lib/Controller/LogController.php' line 102"}}

These entries keep popping up as long as I keep the logging webview open.

Is this the first time you’ve seen this error? No:

By analyzing the log file with grep I found that the issue first started on 2023-08-28 (almost a year ago), when I conducted some major updates. Analyzing the “version” tag in the log entries, it seems that I upgraded from 25.0.2.3 to 27.0.2.1 on that day using multiple incremental steps).

They still appear today, after I upgraded to 29.0.4 (so it’s not related to some old and unsupported version).

Steps to replicate it:

  1. Open /admin/logging in any webbrowser
  2. Wait a few seconds

The output of your Nextcloud log in Admin > Logging:

See above.

A new log entry of this kind is generated every few seconds, more specifically whenever the logreader-main.mjs script generates an XHR to Login – Nextcloud<req_id_here>.

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'nc.my.domain',
  ),
  'trusted_proxies' => 
  array (
    0 => 'ip.addr.of.proxy',
  ),
  'datadirectory' => '/var/nc_data',
  'dbtype' => 'mysql',
  'version' => '29.0.4.1',
  'overwrite.cli.url' => 'https://nc.my.domain',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'instanceid' => 'REDACTED',
  'activity_expire_days' => 14,
  'auth.bruteforce.protection.enabled' => true,
  'blacklisted_files' => 
  array (
    0 => '.htaccess',
    1 => 'Thumbs.db',
    2 => 'thumbs.db',
  ),
  'default_phone_region' => 'DE',
  'cron_log' => true,
  'enable_previews' => true,
  'enabledPreviewProviders' => 
  array (
    0 => 'OC\Preview\PNG',
    1 => 'OC\Preview\JPEG',
    2 => 'OC\Preview\GIF',
    3 => 'OC\Preview\BMP',
    4 => 'OC\Preview\XBitmap',
    5 => 'OC\Preview\Movie',
    6 => 'OC\Preview\PDF',
    7 => 'OC\Preview\MP3',
    8 => 'OC\Preview\TXT',
    9 => 'OC\Preview\MarkDown',
  ),
  'filesystem_check_changes' => 0,
  'filelocking.enabled' => 'true',
  'htaccess.RewriteBase' => '/',
  'integrity.check.disabled' => false,
  'knowledgebaseenabled' => false,
  'logfile' => '/var/nc_data/nextcloud.log',
  'loglevel' => 0,
  'logtimezone' => 'Europe/Berlin',
  'log_rotate_size' => 104857600,
  'maintenance' => false,
  'maintenance_window_start' => 2,
  'memcache.local' => '\OC\Memcache\APCu',
  'memcache.locking' => '\OC\Memcache\Redis',
  #sollte Logout-Issue beheben: https://github.com/nextcloud/server/issues/1075#issuecomment-274376615
  'forcessl' => true,
  'overwriteprotocol' => 'https',
  'overwritehost' => 'nc.my.domain',
  'preview_max_x' => 1024,
  'preview_max_y' => 768,
  'preview_max_scale_factor' => 1,
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'quota_include_external_storage' => false,
  'share_folder' => '/Shares',
  'skeletondirectory' => '',
  'theme' => '',
  'trashbin_retention_obligation' => 'auto, 7',
  'updater.release.channel' => 'stable',
  'app_install_overwrite' => 
  array (
    0 => 'cookbook',
  ),
  'mail_smtpmode' => 'sendmail',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'nextcloud',
  'mail_domain' => 'my.mail.domain',
);

The output of your Apache/nginx/system log in /var/log/____:

my.public.ip.addr - - [06/Aug/2024:00:27:23 +0200] "GET /settings/admin/logging HTTP/1.0" 200 12420 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:24 +0200] "GET /index.php/apps/files/preview-service-worker.js HTTP/1.0" 200 14649 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:24 +0200] "GET /ocs/v2.php/search/providers?from=%2Fsettings%2Fadmin%2Flogging HTTP/1.0" 200 652 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:24 +0200] "POST /contactsmenu/contacts HTTP/1.0" 200 1711 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:24 +0200] "GET /apps/logreader/api/log?offset=0&query= HTTP/1.0" 200 3558 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:25 +0200] "GET /ocs/v2.php/apps/user_status/api/v1/user_status HTTP/1.0" 200 151 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:25 +0200] "PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json HTTP/1.0" 200 151 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:25 +0200] "GET /index.php/apps/files/preview-service-worker.js HTTP/1.0" 200 14649 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:25 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.0" 200 81 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
my.public.ip.addr - - [06/Aug/2024:00:27:34 +0200] "GET /apps/logreader/api/poll?lastReqId=YL1Hu2bm8qyk04BhrhNj HTTP/1.0" 500 2606 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
[... multiple of these 500 status code messages thereafter ...]

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

Isn't this the same as /admin/logging that I already described above?

Further information:
I originally described this issue on GitHub ([Bug]: LogController fails to poll after some update · Issue #1330 · nextcloud/logreader · GitHub).
I was told that this most likely is a configuration issue, e.g., related to opcache.save_comments. Therefore, I quadruple-checked my php.ini (both /etc/php/8.1/fpm/php.ini and /etc/php/8.1/cli/php.ini) and found no obvious flaws:

egrep -v "^;|^\[|^$" /etc/php/8.1/fpm/php.ini 
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = -1
disable_functions = 
disable_classes =
zend.enable_gc = On
zend.exception_ignore_args = On
zend.exception_string_param_max_len = 0
expose_php = Off
max_execution_time = 30
max_input_time = 60
memory_limit = 512M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
cli_server.color = On
pdo_mysql.default_socket=
SMTP = localhost
smtp_port = 25
mail.add_x_header = Off
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
bcmath.scale = 0
session.save_handler = files
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.cookie_samesite =
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.sid_length = 26
session.trans_sid_tags = "a=href,area=href,frame=src,form="
session.sid_bits_per_character = 5
zend.assertions = -1
tidy.clean_output = Off
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
ldap.max_links = -1
opcache.enable_cli=1
opcache.interned_strings_buffer=16
opcache.save_comments=1

(I explicitely included the last line, opcache.save_comments=1, as I was instructed that this might be the culprit, even though it should be the default value in PHP8.1 and it seemed to have been active already.

I went on to also check my webserver configuration and found no mistake visible to me. I took special care with this step after finding a similar issue on GitHub ([Bug]: NC28 syntax error accessing /settings/admin/logging · Issue #1073 · nextcloud/logreader · GitHub). This issue is large and mixes up several individual problems, but many people seemed to have issues with correctly serving mjs files. I made sure that this part is correct in my nginc config:

cat /etc/nginx/conf.d/nextcloud.conf 
map $arg_v $asset_immutable {
	"" "";
	default ", immutable";
}

server {
	listen 80 default_server;
	listen [::]:80 default_server;
	server_name nc.pklb.de;

	server_tokens off;

	add_header Referrer-Policy "no-referrer" always;
	add_header X-Content-Type-Options "nosniff" always;
	#add_header X-Download-Options "noopen" always;
	add_header X-Frame-Options "SAMEORIGIN" always;
	add_header X-Permitted-Cross-Domain-Policies "none" always;
	add_header X-Robots-Tag "noindex, nofollow" always;
	add_header X-XSS-Protection "1; mode=block" always;
	add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;" always;

	fastcgi_hide_header X-Powered-By;
	fastcgi_read_timeout 3600;
	fastcgi_send_timeout 3600;
	fastcgi_connect_timeout 3600;

	root /var/www/nextcloud;

	client_max_body_size 10240M;
	fastcgi_buffers 64 4K;

	gzip on;
	gzip_vary on;
	gzip_comp_level 4;
	gzip_min_length 256;
	gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
	gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

	client_body_buffer_size 512k;

	include mime.types;
	types {
		text/javascript mjs;
		application/wasm wasm;
	}

	index index.php index.html /index.php$request_uri;

	location = / {
		if ( $http_user_agent ~ ^DavClnt ) {
			return 302 /remote.php/webdav/$is_args$args;
		}
	}

	location = /robots.txt {
		allow all;
		log_not_found off;
		access_log off;
	}

	location ^~ /.well-known {
		location = /.well-known/carddav { return 301 /remote.php/dav/; }
		location = /.well-known/caldav  { return 301 /remote.php/dav/; }
		location ^~ /.well-known	{ return 301 /index.php$uri; }
		
		try_files $uri $uri/ =404;
	}

	location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
	location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)	   { return 404; }

	location ~ \.php(?:$|/) {
		rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;

		fastcgi_split_path_info ^(.+?\.php)(\/.*)$;
		set $path_info $fastcgi_path_info;
		try_files $fastcgi_script_name =404;
	
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param PATH_INFO $path_info;
		fastcgi_param HTTPS on;

		fastcgi_param modHeadersAvailable true;
		fastcgi_param front_controller_active true;
		fastcgi_pass php-handler;

		fastcgi_intercept_errors on;
		fastcgi_request_buffering off;

		fastcgi_max_temp_file_size 0;
	}

	location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|webp|wasm|tflite|map|ogg|flac)$ {
		try_files $uri /index.php$request_uri;
		add_header Cache-Control "public, max-age=15778463$asset_immutable";
		add_header Referrer-Policy "no-referrer" always;
		add_header X-Content-Type-Options "nosniff" always;
		add_header X-Frame-Options "SAMEORIGIN" always;
		add_header X-Permitted-Cross-Domain-Policies "none" always;
		add_header X-Robots-Tag "noindex, nofollow" always;
		add_header X-XSS-Protection "1; mode=block" always;
		access_log off;
	}

	location ~ \.woff2?$ {
		try_files $uri /index.php$request_uri;
		expires 7d;
		access_log off;
	}

	location ^~ /apps/rainloop/app/data {
		deny all;
	}

	location /remote {
		return 301 /remote.php?$request_uri;
	}

	location / {
		try_files $uri $uri/ /index.php?request_uri;
	}
}

I am accessing Nextcloud through a reverse proxy so there is no HTTPS in here.

Should be:

	location / {
		try_files $uri $uri/ /index.php?$request_uri;
	}

It could very well be this. The logging logs the contents of $request_uri directly (effectively), so that would explain why the request URI looks correct in the logs, but isn’t matching the behavior you’re seeing.

Essentially the error suggests there isn’t a request_uri being provided to the API call, but the log entry itself shows it being there. That baffled me, until I saw this. :slight_smile:

1 Like

Oh my, that was a sneaky one. Thank you!

Your tip was almost correct.
The correct syntax is /index.php$request_uri (that is, without the question mark).

Therefore, this should also have impacted my /remote endpoint.

And I have to thank you again! Turns out this has also fixed my other issue with failed CSRF checks on logout :slight_smile: (CSRF check failed on logout).

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.